From 11fad0132dc4fa71cd317400bef4fb705ac68bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=9F=E5=B8=85?= <133814250@qq.com> Date: Wed, 18 Jan 2023 17:31:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dvite=E6=89=93=E5=8C=85?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/build/vite/plugin/index.ts | 10 +++++++++- web/src/views/test/index.vue | 9 +-------- web/src/views/test/model.ts | 3 --- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/web/build/vite/plugin/index.ts b/web/build/vite/plugin/index.ts index ce7dd72..0f62f80 100644 --- a/web/build/vite/plugin/index.ts +++ b/web/build/vite/plugin/index.ts @@ -1,7 +1,7 @@ import type { Plugin } from 'vite'; import Components from 'unplugin-vue-components/vite'; import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'; - +import topLevelAwait from 'vite-plugin-top-level-await'; import vue from '@vitejs/plugin-vue'; import vueJsx from '@vitejs/plugin-vue-jsx'; @@ -23,6 +23,14 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean, prodMock) dts: true, resolvers: [NaiveUiResolver()], }), + + // 支持顶级wait + topLevelAwait({ + // The export name of top-level await promise for each chunk module + promiseExportName: '__tla', + // The function to generate import names of top-level await promise in each chunk module + promiseImportName: (i) => `__tla_${i}`, + }), ]; // vite-plugin-html diff --git a/web/src/views/test/index.vue b/web/src/views/test/index.vue index 7f40479..9784f70 100644 --- a/web/src/views/test/index.vue +++ b/web/src/views/test/index.vue @@ -31,12 +31,7 @@ size="small" >