Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use asyncChunks instead of babel-plugin-dynamic-import-node #784

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading