From 19687f187753db8bb7b170d7dbc9b954a9d1326e Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Fri, 18 Oct 2024 12:37:02 +0800 Subject: [PATCH] fix: use asyncChunks instead of babel-plugin-dynamic-import-node (#784) * fix: use asyncChunks instead of babel-plugin-dynamic-import-node * fix: update lock --- src/builder/bundle/index.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/builder/bundle/index.ts b/src/builder/bundle/index.ts index 548a2d54..2cf8d7ea 100644 --- a/src/builder/bundle/index.ts +++ b/src/builder/bundle/index.ts @@ -31,7 +31,9 @@ interface IBundleOpts { incremental?: boolean; } -function bundle(opts: Omit): Promise; +function bundle( + opts: Omit, +): Promise; function bundle(opts: IBundleOpts): Promise; async function bundle(opts: IBundleOpts): Promise { const enableCache = process.env.FATHER_CACHE !== 'none'; @@ -111,7 +113,6 @@ async function bundle(opts: IBundleOpts): Promise { }, ], beforeBabelPlugins: [ - require.resolve('babel-plugin-dynamic-import-node'), ...(babelSCOpts ? [[require.resolve('babel-plugin-styled-components'), babelSCOpts]] : []), @@ -122,7 +123,11 @@ async function bundle(opts: IBundleOpts): Promise { // configure library related options chainWebpack(memo: any) { memo.output.libraryTarget('umd'); - + memo.merge({ + output: { + asyncChunks: false, + }, + }); if (config?.name) { memo.output.library(config.name); } @@ -165,21 +170,21 @@ async function bundle(opts: IBundleOpts): Promise { // enable webpack persistent cache ...(enableCache ? { - cache: { - buildDependencies: opts.buildDependencies, - }, - } + cache: { + buildDependencies: opts.buildDependencies, + }, + } : {}), // collect close handlers for watch mode ...(opts.watch ? { - onBuildComplete({ isFirstCompile, close }: any) { - if (isFirstCompile) closeHandlers.push(close); - // log for watch mode - else logStatus(); - }, - } + onBuildComplete({ isFirstCompile, close }: any) { + if (isFirstCompile) closeHandlers.push(close); + // log for watch mode + else logStatus(); + }, + } : {}), disableCopy: true, });