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" >