From b10bd2346805c08d2ca97accca22d3c7c0746e7b Mon Sep 17 00:00:00 2001 From: shizhong <124974919@qq.com> Date: Tue, 13 Jun 2023 11:04:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8vue3+vite3=20?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=B8=AD=E4=BD=BF=E7=94=A8=E9=A1=B6=E5=B1=82?= =?UTF-8?q?await=E6=89=93=E5=8C=85=E7=9A=84=E6=97=B6=E5=80=99=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/vite/index.ts | 9 ++++++++- package.json | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/build/vite/index.ts b/build/vite/index.ts index dcec1aed..50c51d03 100644 --- a/build/vite/index.ts +++ b/build/vite/index.ts @@ -11,6 +11,7 @@ import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import viteCompression from 'vite-plugin-compression' +import topLevelAwait from 'vite-plugin-top-level-await' import vueSetupExtend from 'vite-plugin-vue-setup-extend' import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' @@ -95,6 +96,12 @@ export function createVitePlugins() { ext: '.gz', // 生成的压缩包后缀 deleteOriginFile: false //压缩后是否删除源文件 }), - ViteEjsPlugin() + ViteEjsPlugin(), + 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}` + }) ] } diff --git a/package.json b/package.json index 9d65c6ea..8080e5a3 100644 --- a/package.json +++ b/package.json @@ -122,6 +122,7 @@ "vite-plugin-progress": "^0.0.6", "vite-plugin-purge-icons": "^0.9.2", "vite-plugin-svg-icons": "^2.0.1", + "vite-plugin-top-level-await": "^1.3.0", "vite-plugin-vue-setup-extend": "^0.4.0", "vite-plugin-windicss": "^1.8.10", "vue-tsc": "^1.2.0",