首页 > 其他分享 >vite打包记录

vite打包记录

时间:2022-10-17 17:36:16浏览次数:46  
标签:level -- top await vite 记录 打包 plugin

error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided

解决办法

// 修改package.json
 "build": "vue-tsc --noEmit --skipLibCheck && vite build",

ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2019", "firefox78", "safari13.1")

主要是因为顶级await导致的

解决办法

1. 安装vite-plugin-top-level-await包(网上的,我用起来没用)

npm install vite-plugin-top-level-await -D
// vue.config.ts中
import topLevelAwait from 'vite-plugin-top-level-await'

export default defineConfig({
  plugins: [
    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}`
    })
  ]
});

2. 老老实实用async+await

标签:level,--,top,await,vite,记录,打包,plugin
From: https://www.cnblogs.com/fengzzi/p/16799952.html

相关文章