Skip to content

Commit

Permalink
refactor: disable dynamic chunks for umd mode
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Sep 6, 2022
1 parent 6d7ae8f commit 47370d5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@umijs/core": "^4.0.17",
"@umijs/utils": "^4.0.17",
"@vercel/ncc": "0.33.3",
"babel-plugin-dynamic-import-node": "2.3.3",
"babel-plugin-module-resolver": "4.1.0",
"babel-plugin-react-require": "3.1.3",
"babel-plugin-transform-define": "2.0.1",
Expand Down
16 changes: 3 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/builder/bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default async (opts: {
pluginDynamicImportNode: false,
},
],
beforeBabelPlugins: [require.resolve('babel-plugin-dynamic-import-node')],
extraBabelPresets: config.extraBabelPresets,
extraBabelPlugins: config.extraBabelPlugins,

Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/build/bundle-dynamic-import/.fatherrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
umd: {},
};
4 changes: 4 additions & 0 deletions tests/fixtures/build/bundle-dynamic-import/expect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default (files: Record<string, string>) => {
// expect single dist file (no async chunks)
expect(Object.keys(files)).toHaveLength(1);
};
1 change: 1 addition & 0 deletions tests/fixtures/build/bundle-dynamic-import/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions tests/fixtures/build/bundle-dynamic-import/src/dynamic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => {};
3 changes: 3 additions & 0 deletions tests/fixtures/build/bundle-dynamic-import/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default async () => {
(await import('./dynamic')).default();
};

0 comments on commit 47370d5

Please sign in to comment.