Skip to content

Commit

Permalink
fix: use asyncChunks instead of babel-plugin-dynamic-import-node (#784)
Browse files Browse the repository at this point in the history
* fix: use asyncChunks instead of babel-plugin-dynamic-import-node

* fix: update lock
  • Loading branch information
Jinbao1001 authored Oct 18, 2024
1 parent d647e1b commit 19687f1
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/builder/bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ interface IBundleOpts {
incremental?: boolean;
}

function bundle(opts: Omit<IBundleOpts, 'watch' | 'incremental'>): Promise<void>;
function bundle(
opts: Omit<IBundleOpts, 'watch' | 'incremental'>,
): Promise<void>;
function bundle(opts: IBundleOpts): Promise<IBundleWatcher>;
async function bundle(opts: IBundleOpts): Promise<void | IBundleWatcher> {
const enableCache = process.env.FATHER_CACHE !== 'none';
Expand Down Expand Up @@ -111,7 +113,6 @@ async function bundle(opts: IBundleOpts): Promise<void | IBundleWatcher> {
},
],
beforeBabelPlugins: [
require.resolve('babel-plugin-dynamic-import-node'),
...(babelSCOpts
? [[require.resolve('babel-plugin-styled-components'), babelSCOpts]]
: []),
Expand All @@ -122,7 +123,11 @@ async function bundle(opts: IBundleOpts): Promise<void | IBundleWatcher> {
// configure library related options
chainWebpack(memo: any) {
memo.output.libraryTarget('umd');

memo.merge({
output: {
asyncChunks: false,
},
});
if (config?.name) {
memo.output.library(config.name);
}
Expand Down Expand Up @@ -165,21 +170,21 @@ async function bundle(opts: IBundleOpts): Promise<void | IBundleWatcher> {
// 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,
});
Expand Down

0 comments on commit 19687f1

Please sign in to comment.