@modern-js/builder 2.26.0 → 2.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/createBuilder.d.ts +1 -1
  3. package/dist/createBuilder.js +48 -38
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +24 -8
  6. package/dist/plugins/antd.d.ts +1 -1
  7. package/dist/plugins/antd.js +51 -31
  8. package/dist/plugins/arco.d.ts +1 -1
  9. package/dist/plugins/arco.js +41 -34
  10. package/dist/plugins/asset.d.ts +1 -1
  11. package/dist/plugins/asset.js +29 -25
  12. package/dist/plugins/assetsRetry.d.ts +1 -1
  13. package/dist/plugins/assetsRetry.js +34 -51
  14. package/dist/plugins/bundleAnalyzer.d.ts +1 -1
  15. package/dist/plugins/bundleAnalyzer.js +29 -50
  16. package/dist/plugins/cache.d.ts +1 -1
  17. package/dist/plugins/cache.js +68 -87
  18. package/dist/plugins/checkSyntax.d.ts +1 -1
  19. package/dist/plugins/checkSyntax.js +40 -54
  20. package/dist/plugins/cleanOutput.d.ts +1 -1
  21. package/dist/plugins/cleanOutput.js +22 -38
  22. package/dist/plugins/devtool.d.ts +1 -1
  23. package/dist/plugins/devtool.js +23 -21
  24. package/dist/plugins/entry.d.ts +1 -1
  25. package/dist/plugins/entry.js +23 -19
  26. package/dist/plugins/externals.d.ts +1 -1
  27. package/dist/plugins/externals.js +28 -25
  28. package/dist/plugins/fileSize.d.ts +1 -1
  29. package/dist/plugins/fileSize.js +124 -130
  30. package/dist/plugins/html.d.ts +1 -1
  31. package/dist/plugins/html.js +204 -206
  32. package/dist/plugins/index.d.ts +1 -1
  33. package/dist/plugins/index.js +41 -53
  34. package/dist/plugins/inlineChunk.d.ts +1 -1
  35. package/dist/plugins/inlineChunk.js +50 -59
  36. package/dist/plugins/moment.d.ts +1 -1
  37. package/dist/plugins/moment.js +23 -20
  38. package/dist/plugins/nodeAddons.d.ts +2 -0
  39. package/dist/plugins/nodeAddons.js +48 -0
  40. package/dist/plugins/rem.d.ts +1 -1
  41. package/dist/plugins/rem.js +73 -98
  42. package/dist/plugins/sourceBuild.d.ts +8 -14
  43. package/dist/plugins/sourceBuild.js +81 -111
  44. package/dist/plugins/splitChunks.d.ts +1 -1
  45. package/dist/plugins/splitChunks.js +206 -229
  46. package/dist/plugins/startUrl.d.ts +1 -1
  47. package/dist/plugins/startUrl.js +62 -78
  48. package/dist/plugins/svg.d.ts +1 -1
  49. package/dist/plugins/svg.js +64 -81
  50. package/dist/plugins/target.d.ts +1 -1
  51. package/dist/plugins/target.js +52 -31
  52. package/dist/plugins/toml.d.ts +1 -1
  53. package/dist/plugins/toml.js +16 -15
  54. package/dist/plugins/tsChecker.d.ts +1 -1
  55. package/dist/plugins/tsChecker.js +79 -92
  56. package/dist/plugins/wasm.d.ts +1 -1
  57. package/dist/plugins/wasm.js +31 -32
  58. package/dist/plugins/yaml.d.ts +1 -1
  59. package/dist/plugins/yaml.js +16 -15
  60. package/package.json +11 -9
@@ -1,96 +1,77 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "builderPluginCache", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return builderPluginCache;
9
+ }
17
10
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.builderPluginCache = void 0;
27
- const path_1 = require("path");
28
- const builder_shared_1 = require("@modern-js/builder-shared");
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _path = require("path");
13
+ const _buildershared = require("@modern-js/builder-shared");
29
14
  async function validateCache(cacheDirectory, buildDependencies) {
30
- const { fs } = await Promise.resolve().then(() => __importStar(require('@modern-js/utils')));
31
- const configFile = (0, path_1.join)(cacheDirectory, 'buildDependencies.json');
32
- if (await (0, builder_shared_1.isFileExists)(configFile)) {
33
- const prevBuildDependencies = await fs.readJSON(configFile);
34
- if (JSON.stringify(prevBuildDependencies) ===
35
- JSON.stringify(buildDependencies)) {
36
- return;
37
- }
38
- /**
39
- * If the filenames in the buildDependencies are changed, webpack will not invalidate the previous cache.
40
- * So we need to remove the cache directory to make sure the cache is invalidated.
41
- */
42
- await fs.remove(cacheDirectory);
15
+ const { fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
16
+ const configFile = (0, _path.join)(cacheDirectory, "buildDependencies.json");
17
+ if (await (0, _buildershared.isFileExists)(configFile)) {
18
+ const prevBuildDependencies = await fs.readJSON(configFile);
19
+ if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) {
20
+ return;
43
21
  }
44
- await fs.outputJSON(configFile, buildDependencies);
22
+ await fs.remove(cacheDirectory);
23
+ }
24
+ await fs.outputJSON(configFile, buildDependencies);
45
25
  }
46
26
  function getCacheDirectory({ cacheDirectory }, context) {
47
- if (cacheDirectory) {
48
- return (0, path_1.isAbsolute)(cacheDirectory)
49
- ? cacheDirectory
50
- : (0, path_1.join)(context.rootPath, cacheDirectory);
51
- }
52
- return (0, path_1.join)(context.cachePath, context.bundlerType);
27
+ if (cacheDirectory) {
28
+ return (0, _path.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, _path.join)(context.rootPath, cacheDirectory);
29
+ }
30
+ return (0, _path.join)(context.cachePath, context.bundlerType);
53
31
  }
54
32
  const builderPluginCache = () => ({
55
- name: 'builder-plugin-cache',
56
- setup(api) {
57
- api.modifyBundlerChain(async (chain, { target, env }) => {
58
- const { buildCache } = api.getNormalizedConfig().performance;
59
- if (buildCache === false) {
60
- chain.cache(false);
61
- return;
62
- }
63
- const { context } = api;
64
- const cacheConfig = typeof buildCache === 'boolean' ? {} : buildCache;
65
- const cacheDirectory = getCacheDirectory(cacheConfig, context);
66
- const rootPackageJson = (0, path_1.join)(context.rootPath, 'package.json');
67
- const browserslistConfig = (0, path_1.join)(context.rootPath, '.browserslistrc');
68
- /**
69
- * webpack can't detect the changes of framework config, tsconfig and browserslist config.
70
- * but they will affect the compilation result, so they need to be added to buildDependencies.
71
- */
72
- const buildDependencies = {
73
- packageJson: [rootPackageJson],
74
- };
75
- if (context.configPath) {
76
- buildDependencies.config = [context.configPath];
77
- }
78
- if (context.tsconfigPath) {
79
- buildDependencies.tsconfig = [context.tsconfigPath];
80
- }
81
- if (await (0, builder_shared_1.isFileExists)(browserslistConfig)) {
82
- buildDependencies.browserslistrc = [browserslistConfig];
83
- }
84
- await validateCache(cacheDirectory, buildDependencies);
85
- chain.cache({
86
- // The default cache name of webpack is '${name}-${env}', and the `name` is `default` by default.
87
- // We set cache name to avoid cache conflicts of different targets.
88
- name: `${target}-${env}`,
89
- type: 'filesystem',
90
- cacheDirectory,
91
- buildDependencies,
92
- });
93
- });
94
- },
33
+ name: "builder-plugin-cache",
34
+ setup(api) {
35
+ api.modifyBundlerChain(async (chain, { target, env }) => {
36
+ const { buildCache } = api.getNormalizedConfig().performance;
37
+ if (buildCache === false) {
38
+ chain.cache(false);
39
+ return;
40
+ }
41
+ const { context } = api;
42
+ const cacheConfig = typeof buildCache === "boolean" ? {} : buildCache;
43
+ const cacheDirectory = getCacheDirectory(cacheConfig, context);
44
+ const rootPackageJson = (0, _path.join)(context.rootPath, "package.json");
45
+ const browserslistConfig = (0, _path.join)(context.rootPath, ".browserslistrc");
46
+ const buildDependencies = {
47
+ packageJson: [
48
+ rootPackageJson
49
+ ]
50
+ };
51
+ if (context.configPath) {
52
+ buildDependencies.config = [
53
+ context.configPath
54
+ ];
55
+ }
56
+ if (context.tsconfigPath) {
57
+ buildDependencies.tsconfig = [
58
+ context.tsconfigPath
59
+ ];
60
+ }
61
+ if (await (0, _buildershared.isFileExists)(browserslistConfig)) {
62
+ buildDependencies.browserslistrc = [
63
+ browserslistConfig
64
+ ];
65
+ }
66
+ await validateCache(cacheDirectory, buildDependencies);
67
+ chain.cache({
68
+ // The default cache name of webpack is '${name}-${env}', and the `name` is `default` by default.
69
+ // We set cache name to avoid cache conflicts of different targets.
70
+ name: `${target}-${env}`,
71
+ type: "filesystem",
72
+ cacheDirectory,
73
+ buildDependencies
74
+ });
75
+ });
76
+ }
95
77
  });
96
- exports.builderPluginCache = builderPluginCache;
@@ -1,2 +1,2 @@
1
1
  import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
- export declare function builderPluginCheckSyntax(): DefaultBuilderPlugin;
2
+ export declare function builderPluginCheckSyntax(): DefaultBuilderPlugin;
@@ -1,60 +1,46 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "builderPluginCheckSyntax", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return builderPluginCheckSyntax;
9
+ }
17
10
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.builderPluginCheckSyntax = void 0;
27
- const builder_shared_1 = require("@modern-js/builder-shared");
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _buildershared = require("@modern-js/builder-shared");
28
13
  function builderPluginCheckSyntax() {
29
- return {
30
- name: 'builder-plugin-check-syntax',
31
- setup(api) {
32
- api.modifyBundlerChain(async (chain, { isProd, target }) => {
33
- const config = api.getNormalizedConfig();
34
- const { checkSyntax } = config.security;
35
- if (!isProd ||
36
- ['node', 'web-worker'].includes(target) ||
37
- !checkSyntax) {
38
- return;
39
- }
40
- const targets = await getCheckTargets(api.context, config, target, checkSyntax);
41
- const { CheckSyntaxPlugin } = await Promise.resolve().then(() => __importStar(require('@modern-js/builder-shared')));
42
- chain.plugin(CheckSyntaxPlugin.name).use(CheckSyntaxPlugin, [
43
- {
44
- targets,
45
- exclude: typeof checkSyntax === 'object' ? checkSyntax.exclude : undefined,
46
- },
47
- ]);
48
- });
49
- },
50
- };
14
+ return {
15
+ name: "builder-plugin-check-syntax",
16
+ setup(api) {
17
+ api.modifyBundlerChain(async (chain, { isProd, target }) => {
18
+ const config = api.getNormalizedConfig();
19
+ const { checkSyntax } = config.security;
20
+ if (!isProd || [
21
+ "node",
22
+ "web-worker"
23
+ ].includes(target) || !checkSyntax) {
24
+ return;
25
+ }
26
+ const targets = await getCheckTargets(api.context, config, target, checkSyntax);
27
+ const { CheckSyntaxPlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared")));
28
+ chain.plugin(CheckSyntaxPlugin.name).use(CheckSyntaxPlugin, [
29
+ {
30
+ targets,
31
+ ...typeof checkSyntax === "object" ? checkSyntax : {}
32
+ }
33
+ ]);
34
+ });
35
+ }
36
+ };
51
37
  }
52
- exports.builderPluginCheckSyntax = builderPluginCheckSyntax;
53
38
  async function getCheckTargets(builderContext, builderConfig, builderTarget, checkSyntax) {
54
- var _a, _b;
55
- const browserslist = (_a = (await (0, builder_shared_1.getBrowserslistWithDefault)(builderContext.rootPath, builderConfig, builderTarget))) !== null && _a !== void 0 ? _a : builder_shared_1.DEFAULT_BROWSERSLIST[builderTarget];
56
- if (checkSyntax === true) {
57
- return browserslist;
58
- }
59
- return (_b = checkSyntax.targets) !== null && _b !== void 0 ? _b : browserslist;
39
+ var _ref;
40
+ const browserslist = (_ref = await (0, _buildershared.getBrowserslistWithDefault)(builderContext.rootPath, builderConfig, builderTarget)) !== null && _ref !== void 0 ? _ref : _buildershared.DEFAULT_BROWSERSLIST[builderTarget];
41
+ if (checkSyntax === true) {
42
+ return browserslist;
43
+ }
44
+ var _checkSyntax_targets;
45
+ return (_checkSyntax_targets = checkSyntax.targets) !== null && _checkSyntax_targets !== void 0 ? _checkSyntax_targets : browserslist;
60
46
  }
@@ -1,2 +1,2 @@
1
1
  import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
- export declare const builderPluginCleanOutput: () => DefaultBuilderPlugin;
2
+ export declare const builderPluginCleanOutput: () => DefaultBuilderPlugin;
@@ -1,42 +1,26 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
17
4
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.builderPluginCleanOutput = void 0;
5
+ Object.defineProperty(exports, "builderPluginCleanOutput", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return builderPluginCleanOutput;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
27
12
  const builderPluginCleanOutput = () => ({
28
- name: 'builder-plugin-clean-output',
29
- setup(api) {
30
- const clean = async () => {
31
- const config = api.getNormalizedConfig();
32
- if (config.output.cleanDistPath) {
33
- const { emptyDir } = await Promise.resolve().then(() => __importStar(require('@modern-js/utils')));
34
- const { distPath } = api.context;
35
- await emptyDir(distPath);
36
- }
37
- };
38
- api.onBeforeBuild(clean);
39
- api.onBeforeStartDevServer(clean);
40
- },
13
+ name: "builder-plugin-clean-output",
14
+ setup(api) {
15
+ const clean = async () => {
16
+ const config = api.getNormalizedConfig();
17
+ if (config.output.cleanDistPath) {
18
+ const { emptyDir } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
19
+ const { distPath } = api.context;
20
+ await emptyDir(distPath);
21
+ }
22
+ };
23
+ api.onBeforeBuild(clean);
24
+ api.onBeforeStartDevServer(clean);
25
+ }
41
26
  });
42
- exports.builderPluginCleanOutput = builderPluginCleanOutput;
@@ -1,2 +1,2 @@
1
1
  import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
- export declare const builderPluginDevtool: () => DefaultBuilderPlugin;
2
+ export declare const builderPluginDevtool: () => DefaultBuilderPlugin;
@@ -1,24 +1,26 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.builderPluginDevtool = void 0;
4
- const builder_shared_1 = require("@modern-js/builder-shared");
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "builderPluginDevtool", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return builderPluginDevtool;
9
+ }
10
+ });
11
+ const _buildershared = require("@modern-js/builder-shared");
5
12
  const builderPluginDevtool = () => ({
6
- name: 'builder-plugin-devtool',
7
- setup(api) {
8
- api.modifyBundlerChain((chain, { isProd, isServer }) => {
9
- const config = api.getNormalizedConfig();
10
- if (!(0, builder_shared_1.isUseJsSourceMap)(config)) {
11
- chain.devtool(false);
12
- }
13
- else {
14
- const prodDevTool = isServer ? 'source-map' : 'hidden-source-map';
15
- const devtool = isProd
16
- ? // hide the source map URL in production to avoid Chrome warning
17
- prodDevTool
18
- : 'cheap-module-source-map';
19
- chain.devtool(devtool);
20
- }
21
- });
22
- },
13
+ name: "builder-plugin-devtool",
14
+ setup(api) {
15
+ api.modifyBundlerChain((chain, { isProd, isServer }) => {
16
+ const config = api.getNormalizedConfig();
17
+ if (!(0, _buildershared.isUseJsSourceMap)(config)) {
18
+ chain.devtool(false);
19
+ } else {
20
+ const prodDevTool = isServer ? "source-map" : "hidden-source-map";
21
+ const devtool = isProd ? prodDevTool : "cheap-module-source-map";
22
+ chain.devtool(devtool);
23
+ }
24
+ });
25
+ }
23
26
  });
24
- exports.builderPluginDevtool = builderPluginDevtool;
@@ -1,2 +1,2 @@
1
1
  import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
- export declare const builderPluginEntry: () => DefaultBuilderPlugin;
2
+ export declare const builderPluginEntry: () => DefaultBuilderPlugin;
@@ -1,22 +1,26 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.builderPluginEntry = void 0;
7
- const lodash_1 = __importDefault(require("@modern-js/utils/lodash"));
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "builderPluginEntry", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return builderPluginEntry;
9
+ }
10
+ });
11
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
+ const _lodash = /* @__PURE__ */ _interop_require_default._(require("@modern-js/utils/lodash"));
8
13
  const builderPluginEntry = () => ({
9
- name: 'builder-plugin-entry',
10
- setup(api) {
11
- api.modifyBundlerChain(async (chain) => {
12
- const { entry } = api.context;
13
- const { preEntry } = api.getNormalizedConfig().source;
14
- Object.keys(entry).forEach(entryName => {
15
- const appendEntry = (file) => chain.entry(entryName).add(file);
16
- preEntry.forEach(appendEntry);
17
- lodash_1.default.castArray(entry[entryName]).forEach(appendEntry);
18
- });
19
- });
20
- },
14
+ name: "builder-plugin-entry",
15
+ setup(api) {
16
+ api.modifyBundlerChain(async (chain) => {
17
+ const { entry } = api.context;
18
+ const { preEntry } = api.getNormalizedConfig().source;
19
+ Object.keys(entry).forEach((entryName) => {
20
+ const appendEntry = (file) => chain.entry(entryName).add(file);
21
+ preEntry.forEach(appendEntry);
22
+ _lodash.default.castArray(entry[entryName]).forEach(appendEntry);
23
+ });
24
+ });
25
+ }
21
26
  });
22
- exports.builderPluginEntry = builderPluginEntry;
@@ -1,2 +1,2 @@
1
1
  import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
- export declare function builderPluginExternals(): DefaultBuilderPlugin;
2
+ export declare function builderPluginExternals(): DefaultBuilderPlugin;
@@ -1,28 +1,31 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.builderPluginExternals = void 0;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "builderPluginExternals", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return builderPluginExternals;
9
+ }
10
+ });
4
11
  function builderPluginExternals() {
5
- return {
6
- name: 'builder-plugin-externals',
7
- setup(api) {
8
- api.modifyBundlerChain(chain => {
9
- const { externals } = api.getNormalizedConfig().output;
10
- if (externals) {
11
- chain.externals(externals);
12
- }
13
- });
14
- api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
15
- bundlerConfigs.forEach(config => {
16
- const isWebWorker = Array.isArray(config.target)
17
- ? config.target.includes('webworker')
18
- : config.target === 'webworker';
19
- // externals will not take effect, the Worker environment can not access global variables.
20
- if (isWebWorker && config.externals) {
21
- delete config.externals;
22
- }
23
- });
24
- });
25
- },
26
- };
12
+ return {
13
+ name: "builder-plugin-externals",
14
+ setup(api) {
15
+ api.modifyBundlerChain((chain) => {
16
+ const { externals } = api.getNormalizedConfig().output;
17
+ if (externals) {
18
+ chain.externals(externals);
19
+ }
20
+ });
21
+ api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
22
+ bundlerConfigs.forEach((config) => {
23
+ const isWebWorker = Array.isArray(config.target) ? config.target.includes("webworker") : config.target === "webworker";
24
+ if (isWebWorker && config.externals) {
25
+ delete config.externals;
26
+ }
27
+ });
28
+ });
29
+ }
30
+ };
27
31
  }
28
- exports.builderPluginExternals = builderPluginExternals;
@@ -1,4 +1,4 @@
1
1
  import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
2
  /** Filter source map and license files */
3
3
  export declare const filterAsset: (asset: string) => boolean;
4
- export declare const builderPluginFileSize: () => DefaultBuilderPlugin;
4
+ export declare const builderPluginFileSize: () => DefaultBuilderPlugin;