sanyuan0704 / vite-plugin-chunk-split

A vite plugin for better chunk splitting. 一个简单易用的 Vite 拆包插件
MIT License
352 stars 22 forks source link

vite.config.js 里按 文档安装后 build 报 vite-plugin-chunk-split/dist/index.cjs not supported.... #43

Open bin-dogami opened 4 months ago

bin-dogami commented 4 months ago

vite 4.0.0 node v17.0.0

配置按 readme 里来的,错误信息如下: Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/yangbin/coding/dmail/dmail-server/web/node_modules/import-meta-resolve/index.js from /Users/yangbin/coding/dmail/dmail-server/web/node_modules/vite-plugin-chunk-split/dist/index.cjs not supported.

antoinelrk-ie commented 3 months ago

Same problem

CherishTheYouth commented 2 months ago

Same Problem

CherishTheYouth commented 2 months ago
// vite.config.ts

export default defineConfig(async ({ mode }) => {
  const env = loadEnv(mode, process.cwd())
  const { chunkSplitPlugin } = await import('vite-plugin-chunk-split')

Use dynamic import to take effect。

hijack-621 commented 1 month ago

// vite.config.ts

export default defineConfig(async ({ mode }) => { const env = loadEnv(mode, process.cwd()) const { chunkSplitPlugin } = await import('vite-plugin-chunk-split')
这里动态导入会报错:ypeError: object is not iterable (cannot read property Symbol(Symbol.iterator)) at Function.all () ules/vite/dist/node/chunks/dep-jDlp at asyncFlatten (file:///D:/2024/quotation/nodemodules/.pnpm/vite@5.1.4@types+node@20.12.7_sass@1.75.0_terser@5.30.4/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:12923:26)

hijack-621 commented 1 month ago

vite版本:"vite": "5.1.4"