Skip to content

Commit 0501983

Browse files
author
puhui999
committed
修复在vue3+vite3 模块中使用顶层await打包的时候报错
1 parent 5f6dc3c commit 0501983

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

build/vite/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import AutoImport from 'unplugin-auto-import/vite'
1212
import Components from 'unplugin-vue-components/vite'
1313
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
1414
import viteCompression from 'vite-plugin-compression'
15+
import topLevelAwait from 'vite-plugin-top-level-await'
1516
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
1617
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
1718
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
@@ -96,6 +97,12 @@ export function createVitePlugins() {
9697
ext: '.gz', // 生成的压缩包后缀
9798
deleteOriginFile: false //压缩后是否删除源文件
9899
}),
99-
ViteEjsPlugin()
100+
ViteEjsPlugin(),
101+
topLevelAwait({
102+
// The export name of top-level await promise for each chunk module
103+
promiseExportName: '__tla',
104+
// The function to generate import names of top-level await promise in each chunk module
105+
promiseImportName: (i) => `__tla_${i}`
106+
})
100107
]
101108
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"vite-plugin-progress": "^0.0.6",
123123
"vite-plugin-purge-icons": "^0.9.2",
124124
"vite-plugin-svg-icons": "^2.0.1",
125+
"vite-plugin-top-level-await": "^1.3.0",
125126
"vite-plugin-vue-setup-extend": "^0.4.0",
126127
"vite-plugin-windicss": "^1.8.10",
127128
"vue-tsc": "^1.2.0",

src/types/auto-components.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ declare module '@vue/runtime-core' {
2323
DictTag: typeof import('./../components/DictTag/src/DictTag.vue')['default']
2424
Echart: typeof import('./../components/Echart/src/Echart.vue')['default']
2525
Editor: typeof import('./../components/Editor/src/Editor.vue')['default']
26+
ElAutoResizer: typeof import('element-plus/es')['ElAutoResizer']
27+
ElAvatar: typeof import('element-plus/es')['ElAvatar']
2628
ElBadge: typeof import('element-plus/es')['ElBadge']
2729
ElButton: typeof import('element-plus/es')['ElButton']
2830
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
@@ -52,6 +54,7 @@ declare module '@vue/runtime-core' {
5254
ElForm: typeof import('element-plus/es')['ElForm']
5355
ElFormItem: typeof import('element-plus/es')['ElFormItem']
5456
ElIcon: typeof import('element-plus/es')['ElIcon']
57+
ElImage: typeof import('element-plus/es')['ElImage']
5558
ElImageViewer: typeof import('element-plus/es')['ElImageViewer']
5659
ElInput: typeof import('element-plus/es')['ElInput']
5760
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
@@ -60,17 +63,22 @@ declare module '@vue/runtime-core' {
6063
ElPagination: typeof import('element-plus/es')['ElPagination']
6164
ElPopover: typeof import('element-plus/es')['ElPopover']
6265
ElRadio: typeof import('element-plus/es')['ElRadio']
66+
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
6367
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
6468
ElRow: typeof import('element-plus/es')['ElRow']
6569
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
6670
ElSelect: typeof import('element-plus/es')['ElSelect']
6771
ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
72+
ElSpace: typeof import('element-plus/es')['ElSpace']
6873
ElSwitch: typeof import('element-plus/es')['ElSwitch']
6974
ElTable: typeof import('element-plus/es')['ElTable']
7075
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
76+
ElTableV2: typeof import('element-plus/es')['ElTableV2']
7177
ElTabPane: typeof import('element-plus/es')['ElTabPane']
7278
ElTabs: typeof import('element-plus/es')['ElTabs']
7379
ElTag: typeof import('element-plus/es')['ElTag']
80+
ElTimeline: typeof import('element-plus/es')['ElTimeline']
81+
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
7482
ElTooltip: typeof import('element-plus/es')['ElTooltip']
7583
ElTree: typeof import('element-plus/es')['ElTree']
7684
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']

src/views/system/mail/template/form.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<template>
2-
<Dialog :title="dialogTitle" v-model="dialogVisible" :scroll="true" :width="800" :max-height="500">
2+
<Dialog
3+
:title="dialogTitle"
4+
v-model="dialogVisible"
5+
:scroll="true"
6+
:width="800"
7+
:max-height="500"
8+
>
39
<Form ref="formRef" :schema="allSchemas.formSchema" :rules="rules" v-loading="formLoading" />
410
<template #footer>
511
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
@@ -9,7 +15,7 @@
915
</template>
1016
<script setup lang="ts">
1117
import * as MailTemplateApi from '@/api/system/mail/template'
12-
import { rules, allSchemas } from './template.data'
18+
import { allSchemas, rules } from './template.data'
1319
1420
const { t } = useI18n() // 国际化
1521
const message = useMessage() // 消息弹窗

0 commit comments

Comments
 (0)