From 0729a57cd295656a6612817f352c339107dce035 Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Thu, 17 Oct 2024 11:22:54 +0800 Subject: [PATCH 1/2] fix: use asyncChunks instead of babel-plugin-dynamic-import-node --- pnpm-lock.yaml | 9 --------- src/builder/bundle/index.ts | 31 ++++++++++++++++++------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e346fb7d..8126675f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,9 +32,6 @@ importers: '@vercel/ncc': specifier: 0.33.3 version: 0.33.3 - babel-plugin-dynamic-import-node: - specifier: 2.3.3 - version: 2.3.3 babel-plugin-module-resolver: specifier: 4.1.0 version: 4.1.0 @@ -4325,12 +4322,6 @@ packages: - supports-color dev: true - /babel-plugin-dynamic-import-node@2.3.3: - resolution: {integrity: sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==} - dependencies: - object.assign: 4.1.4 - dev: false - /babel-plugin-istanbul@6.1.1: resolution: {integrity: sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==} engines: {node: '>=8'} 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, }); From f0ba8923bae40222714cd6bb13ee6f3000e9caf6 Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Thu, 17 Oct 2024 11:27:24 +0800 Subject: [PATCH 2/2] fix: update lock --- pnpm-lock.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8126675f..e346fb7d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,9 @@ importers: '@vercel/ncc': specifier: 0.33.3 version: 0.33.3 + babel-plugin-dynamic-import-node: + specifier: 2.3.3 + version: 2.3.3 babel-plugin-module-resolver: specifier: 4.1.0 version: 4.1.0 @@ -4322,6 +4325,12 @@ packages: - supports-color dev: true + /babel-plugin-dynamic-import-node@2.3.3: + resolution: {integrity: sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==} + dependencies: + object.assign: 4.1.4 + dev: false + /babel-plugin-istanbul@6.1.1: resolution: {integrity: sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==} engines: {node: '>=8'}