@modern-js/builder 2.26.0 → 2.27.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 (58) hide show
  1. package/CHANGELOG.md +19 -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 +52 -30
  8. package/dist/plugins/arco.d.ts +1 -1
  9. package/dist/plugins/arco.js +43 -35
  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 +203 -206
  32. package/dist/plugins/index.d.ts +1 -1
  33. package/dist/plugins/index.js +40 -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/rem.d.ts +1 -1
  39. package/dist/plugins/rem.js +74 -97
  40. package/dist/plugins/sourceBuild.d.ts +12 -12
  41. package/dist/plugins/sourceBuild.js +125 -109
  42. package/dist/plugins/splitChunks.d.ts +1 -1
  43. package/dist/plugins/splitChunks.js +206 -229
  44. package/dist/plugins/startUrl.d.ts +1 -1
  45. package/dist/plugins/startUrl.js +62 -78
  46. package/dist/plugins/svg.d.ts +1 -1
  47. package/dist/plugins/svg.js +64 -81
  48. package/dist/plugins/target.d.ts +1 -1
  49. package/dist/plugins/target.js +52 -31
  50. package/dist/plugins/toml.d.ts +1 -1
  51. package/dist/plugins/toml.js +16 -15
  52. package/dist/plugins/tsChecker.d.ts +1 -1
  53. package/dist/plugins/tsChecker.js +69 -92
  54. package/dist/plugins/wasm.d.ts +1 -1
  55. package/dist/plugins/wasm.js +31 -32
  56. package/dist/plugins/yaml.d.ts +1 -1
  57. package/dist/plugins/yaml.js +16 -15
  58. package/package.json +11 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @modern-js/builder
2
2
 
3
+ ## 2.27.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 8322a51: chore: migrate packages from tsc to module-lib build
8
+
9
+ chore: 将使用 tsc 的包迁移到 module-lib 构建
10
+
11
+ - Updated dependencies [645e111]
12
+ - Updated dependencies [91d14b8]
13
+ - Updated dependencies [8322a51]
14
+ - Updated dependencies [d9080ed]
15
+ - Updated dependencies [67d0b0c]
16
+ - Updated dependencies [3f79dd7]
17
+ - Updated dependencies [6d7104d]
18
+ - @modern-js/builder-shared@2.27.0
19
+ - @modern-js/utils@2.27.0
20
+ - @modern-js/monorepo-utils@2.27.0
21
+
3
22
  ## 2.26.0
4
23
 
5
24
  ### Minor Changes
@@ -1,2 +1,2 @@
1
1
  import { type BuilderInstance, type BuilderProvider, type CreateBuilderOptions } from '@modern-js/builder-shared';
2
- export declare function createBuilder<P extends BuilderProvider = BuilderProvider>(provider: P, options: CreateBuilderOptions): Promise<BuilderInstance<P>>;
2
+ export declare function createBuilder<P extends BuilderProvider = BuilderProvider>(provider: P, options: CreateBuilderOptions): Promise<BuilderInstance<P>>;
@@ -1,41 +1,51 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createBuilder = void 0;
4
- const builder_shared_1 = require("@modern-js/builder-shared");
5
- const plugins_1 = require("./plugins");
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "createBuilder", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return createBuilder;
9
+ }
10
+ });
11
+ const _buildershared = require("@modern-js/builder-shared");
12
+ const _plugins = require("./plugins");
6
13
  async function createBuilder(provider, options) {
7
- const builderOptions = (0, builder_shared_1.applyDefaultBuilderOptions)(options);
8
- const pluginStore = (0, builder_shared_1.createPluginStore)();
9
- const { build, serve, pluginAPI, publicContext, initConfigs, inspectConfig, createCompiler, startDevServer, applyDefaultPlugins, } = await provider({
10
- pluginStore,
11
- builderOptions,
12
- plugins: plugins_1.plugins,
13
- });
14
- (0, builder_shared_1.debug)('add default plugins');
15
- await applyDefaultPlugins(pluginStore);
16
- (0, builder_shared_1.debug)('add default plugins done');
17
- return {
18
- ...(0, builder_shared_1.pick)(pluginStore, ['addPlugins', 'removePlugins', 'isPluginExists']),
19
- ...(0, builder_shared_1.pick)(pluginAPI, [
20
- 'onBeforeBuild',
21
- 'onBeforeCreateCompiler',
22
- 'onBeforeStartDevServer',
23
- 'onAfterBuild',
24
- 'onAfterCreateCompiler',
25
- 'onAfterStartDevServer',
26
- 'onDevCompileDone',
27
- 'onExit',
28
- 'getHTMLPaths',
29
- 'getBuilderConfig',
30
- 'getNormalizedConfig',
31
- ]),
32
- serve,
33
- build,
34
- createCompiler,
35
- initConfigs,
36
- inspectConfig,
37
- startDevServer,
38
- context: publicContext,
39
- };
14
+ const builderOptions = (0, _buildershared.applyDefaultBuilderOptions)(options);
15
+ const pluginStore = (0, _buildershared.createPluginStore)();
16
+ const { build, serve, pluginAPI, publicContext, initConfigs, inspectConfig, createCompiler, startDevServer, applyDefaultPlugins } = await provider({
17
+ pluginStore,
18
+ builderOptions,
19
+ plugins: _plugins.plugins
20
+ });
21
+ (0, _buildershared.debug)("add default plugins");
22
+ await applyDefaultPlugins(pluginStore);
23
+ (0, _buildershared.debug)("add default plugins done");
24
+ return {
25
+ ...(0, _buildershared.pick)(pluginStore, [
26
+ "addPlugins",
27
+ "removePlugins",
28
+ "isPluginExists"
29
+ ]),
30
+ ...(0, _buildershared.pick)(pluginAPI, [
31
+ "onBeforeBuild",
32
+ "onBeforeCreateCompiler",
33
+ "onBeforeStartDevServer",
34
+ "onAfterBuild",
35
+ "onAfterCreateCompiler",
36
+ "onAfterStartDevServer",
37
+ "onDevCompileDone",
38
+ "onExit",
39
+ "getHTMLPaths",
40
+ "getBuilderConfig",
41
+ "getNormalizedConfig"
42
+ ]),
43
+ serve,
44
+ build,
45
+ createCompiler,
46
+ initConfigs,
47
+ inspectConfig,
48
+ startDevServer,
49
+ context: publicContext
50
+ };
40
51
  }
41
- exports.createBuilder = createBuilder;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { createBuilder } from './createBuilder';
2
2
  export { mergeBuilderConfig } from '@modern-js/builder-shared';
3
3
  export { builderPluginSourceBuild } from './plugins/sourceBuild';
4
- export type { BuilderMode, BuilderEntry, BuilderTarget, BuilderPlugin, BuilderContext, BuilderInstance, CreateBuilderOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn, ModifyBuilderConfigFn, } from '@modern-js/builder-shared';
4
+ export type { BuilderMode, BuilderEntry, BuilderTarget, BuilderPlugin, BuilderContext, BuilderInstance, CreateBuilderOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn, ModifyBuilderConfigFn } from '@modern-js/builder-shared';
package/dist/index.js CHANGED
@@ -1,9 +1,25 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.builderPluginSourceBuild = exports.mergeBuilderConfig = exports.createBuilder = void 0;
4
- var createBuilder_1 = require("./createBuilder");
5
- Object.defineProperty(exports, "createBuilder", { enumerable: true, get: function () { return createBuilder_1.createBuilder; } });
6
- var builder_shared_1 = require("@modern-js/builder-shared");
7
- Object.defineProperty(exports, "mergeBuilderConfig", { enumerable: true, get: function () { return builder_shared_1.mergeBuilderConfig; } });
8
- var sourceBuild_1 = require("./plugins/sourceBuild");
9
- Object.defineProperty(exports, "builderPluginSourceBuild", { enumerable: true, get: function () { return sourceBuild_1.builderPluginSourceBuild; } });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for (var name in all)
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ createBuilder: function() {
14
+ return _createBuilder.createBuilder;
15
+ },
16
+ mergeBuilderConfig: function() {
17
+ return _buildershared.mergeBuilderConfig;
18
+ },
19
+ builderPluginSourceBuild: function() {
20
+ return _sourceBuild.builderPluginSourceBuild;
21
+ }
22
+ });
23
+ const _createBuilder = require("./createBuilder");
24
+ const _buildershared = require("@modern-js/builder-shared");
25
+ const _sourceBuild = require("./plugins/sourceBuild");
@@ -1,3 +1,3 @@
1
1
  import type { BuilderTarget, DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
2
  export declare const builderPluginAntd: () => DefaultBuilderPlugin;
3
- export declare function useSSR(target: BuilderTarget | BuilderTarget[]): boolean;
3
+ export declare function useSSR(target: BuilderTarget | BuilderTarget[]): boolean;
@@ -1,36 +1,58 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSSR = exports.builderPluginAntd = void 0;
4
- const utils_1 = require("@modern-js/utils");
5
- const builderPluginAntd = () => ({
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for (var name in all)
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ builderPluginAntd: function() {
14
+ return builderPluginAntd;
15
+ },
16
+ useSSR: function() {
17
+ return useSSR;
18
+ }
19
+ });
20
+ const _utils = require("@modern-js/utils");
21
+ const builderPluginAntd = () => {
22
+ return {
6
23
  name: `builder-plugin-antd`,
7
24
  setup(api) {
8
- api.modifyBuilderConfig(builderConfig => {
9
- var _a, _b, _c;
10
- (_a = builderConfig.source) !== null && _a !== void 0 ? _a : (builderConfig.source = {});
11
- if (builderConfig.source.transformImport === false ||
12
- ((_b = builderConfig.source.transformImport) === null || _b === void 0 ? void 0 : _b.some(item => item.libraryName === 'antd'))) {
13
- return;
25
+ api.modifyBuilderConfig((builderConfig) => {
26
+ var _builderConfig_source_transformImport;
27
+ var _builderConfig;
28
+ var _source;
29
+ (_source = (_builderConfig = builderConfig).source) !== null && _source !== void 0 ? _source : _builderConfig.source = {};
30
+ if (builderConfig.source.transformImport === false || ((_builderConfig_source_transformImport = builderConfig.source.transformImport) === null || _builderConfig_source_transformImport === void 0 ? void 0 : _builderConfig_source_transformImport.some((item) => item.libraryName === "antd"))) {
31
+ return;
32
+ }
33
+ const antdMajorVersion = (0, _utils.getAntdMajorVersion)(api.context.rootPath);
34
+ if (antdMajorVersion && antdMajorVersion < 5) {
35
+ var _builderConfig1;
36
+ var _source1;
37
+ (_source1 = (_builderConfig1 = builderConfig).source) !== null && _source1 !== void 0 ? _source1 : _builderConfig1.source = {};
38
+ builderConfig.source.transformImport = [
39
+ ...builderConfig.source.transformImport || [],
40
+ {
41
+ libraryName: "antd",
42
+ libraryDirectory: useSSR(api.context.target) ? "lib" : "es",
43
+ style: true
14
44
  }
15
- const antdMajorVersion = (0, utils_1.getAntdMajorVersion)(api.context.rootPath);
16
- // antd >= v5 no longer need babel-plugin-import
17
- // see: https://ant.design/docs/react/migration-v5#remove-babel-plugin-import
18
- if (antdMajorVersion && antdMajorVersion < 5) {
19
- (_c = builderConfig.source) !== null && _c !== void 0 ? _c : (builderConfig.source = {});
20
- builderConfig.source.transformImport = [
21
- ...(builderConfig.source.transformImport || []),
22
- {
23
- libraryName: 'antd',
24
- libraryDirectory: useSSR(api.context.target) ? 'lib' : 'es',
25
- style: true,
26
- },
27
- ];
28
- }
29
- });
30
- },
31
- });
32
- exports.builderPluginAntd = builderPluginAntd;
45
+ ];
46
+ }
47
+ });
48
+ }
49
+ };
50
+ };
33
51
  function useSSR(target) {
34
- return (Array.isArray(target) ? target : [target]).some(item => ['node', 'service-worker'].includes(item));
52
+ return (Array.isArray(target) ? target : [
53
+ target
54
+ ]).some((item) => [
55
+ "node",
56
+ "service-worker"
57
+ ].includes(item));
35
58
  }
36
- exports.useSSR = useSSR;
@@ -1,2 +1,2 @@
1
1
  import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
- export declare const builderPluginArco: () => DefaultBuilderPlugin;
2
+ export declare const builderPluginArco: () => DefaultBuilderPlugin;
@@ -1,38 +1,46 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.builderPluginArco = void 0;
4
- const utils_1 = require("@modern-js/utils");
5
- const antd_1 = require("./antd");
6
- const builderPluginArco = () => ({
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "builderPluginArco", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return builderPluginArco;
9
+ }
10
+ });
11
+ const _utils = require("@modern-js/utils");
12
+ const _antd = require("./antd");
13
+ const builderPluginArco = () => {
14
+ return {
7
15
  name: `builder-plugin-arco`,
8
16
  setup(api) {
9
- const ARCO_NAME = '@arco-design/web-react';
10
- const ARCO_ICON = `${ARCO_NAME}/icon`;
11
- api.modifyBuilderConfig(builderConfig => {
12
- const { transformImport = [] } = builderConfig.source || {};
13
- if (transformImport === false ||
14
- !(0, utils_1.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
15
- return;
16
- }
17
- const isUseSSR = (0, antd_1.useSSR)(api.context.target);
18
- if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some(item => item.libraryName === ARCO_NAME))) {
19
- transformImport.push({
20
- libraryName: ARCO_NAME,
21
- libraryDirectory: isUseSSR ? 'lib' : 'es',
22
- camelToDashComponentName: false,
23
- style: true,
24
- });
25
- }
26
- if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some(item => item.libraryName === ARCO_ICON))) {
27
- transformImport.push({
28
- libraryName: ARCO_ICON,
29
- libraryDirectory: isUseSSR ? 'react-icon-cjs' : 'react-icon',
30
- camelToDashComponentName: false,
31
- });
32
- }
33
- builderConfig.source || (builderConfig.source = {});
34
- builderConfig.source.transformImport = transformImport;
35
- });
36
- },
37
- });
38
- exports.builderPluginArco = builderPluginArco;
17
+ const ARCO_NAME = "@arco-design/web-react";
18
+ const ARCO_ICON = `${ARCO_NAME}/icon`;
19
+ api.modifyBuilderConfig((builderConfig) => {
20
+ var _builderConfig;
21
+ const { transformImport = [] } = builderConfig.source || {};
22
+ if (transformImport === false || !(0, _utils.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
23
+ return;
24
+ }
25
+ const isUseSSR = (0, _antd.useSSR)(api.context.target);
26
+ if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some((item) => item.libraryName === ARCO_NAME))) {
27
+ transformImport.push({
28
+ libraryName: ARCO_NAME,
29
+ libraryDirectory: isUseSSR ? "lib" : "es",
30
+ camelToDashComponentName: false,
31
+ style: true
32
+ });
33
+ }
34
+ if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some((item) => item.libraryName === ARCO_ICON))) {
35
+ transformImport.push({
36
+ libraryName: ARCO_ICON,
37
+ libraryDirectory: isUseSSR ? "react-icon-cjs" : "react-icon",
38
+ camelToDashComponentName: false
39
+ });
40
+ }
41
+ (_builderConfig = builderConfig).source || (_builderConfig.source = {});
42
+ builderConfig.source.transformImport = transformImport;
43
+ });
44
+ }
45
+ };
46
+ };
@@ -1,2 +1,2 @@
1
1
  import type { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
- export declare const builderAssetPlugin: (assetType: 'image' | 'media' | 'font', exts: string[]) => DefaultBuilderPlugin;
2
+ export declare const builderAssetPlugin: (assetType: 'image' | 'media' | 'font', exts: string[]) => DefaultBuilderPlugin;
@@ -1,28 +1,32 @@
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.builderAssetPlugin = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const builder_shared_1 = require("@modern-js/builder-shared");
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "builderAssetPlugin", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return builderAssetPlugin;
9
+ }
10
+ });
11
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
+ const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
13
+ const _buildershared = require("@modern-js/builder-shared");
9
14
  const builderAssetPlugin = (assetType, exts) => ({
10
- name: `builder-plugin-${assetType}`,
11
- setup(api) {
12
- api.modifyBundlerChain((chain, { isProd }) => {
13
- const config = api.getNormalizedConfig();
14
- const regExp = (0, builder_shared_1.getRegExpForExts)(exts);
15
- const distDir = (0, builder_shared_1.getDistPath)(config.output, assetType);
16
- const filename = (0, builder_shared_1.getFilename)(config.output, assetType, isProd);
17
- const maxSize = config.output.dataUriLimit[assetType];
18
- const rule = chain.module.rule(assetType).test(regExp);
19
- (0, builder_shared_1.chainStaticAssetRule)({
20
- rule,
21
- maxSize,
22
- filename: path_1.default.posix.join(distDir, filename),
23
- assetType,
24
- });
25
- });
26
- },
15
+ name: `builder-plugin-${assetType}`,
16
+ setup(api) {
17
+ api.modifyBundlerChain((chain, { isProd }) => {
18
+ const config = api.getNormalizedConfig();
19
+ const regExp = (0, _buildershared.getRegExpForExts)(exts);
20
+ const distDir = (0, _buildershared.getDistPath)(config.output, assetType);
21
+ const filename = (0, _buildershared.getFilename)(config.output, assetType, isProd);
22
+ const maxSize = config.output.dataUriLimit[assetType];
23
+ const rule = chain.module.rule(assetType).test(regExp);
24
+ (0, _buildershared.chainStaticAssetRule)({
25
+ rule,
26
+ maxSize,
27
+ filename: _path.default.posix.join(distDir, filename),
28
+ assetType
29
+ });
30
+ });
31
+ }
27
32
  });
28
- exports.builderAssetPlugin = builderAssetPlugin;
@@ -1,2 +1,2 @@
1
1
  import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
- export declare function builderPluginAssetsRetry(): DefaultBuilderPlugin;
2
+ export declare function builderPluginAssetsRetry(): DefaultBuilderPlugin;
@@ -1,55 +1,38 @@
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, "builderPluginAssetsRetry", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return builderPluginAssetsRetry;
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.builderPluginAssetsRetry = 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 builderPluginAssetsRetry() {
29
- return {
30
- name: 'builder-plugin-assets-retry',
31
- setup(api) {
32
- api.modifyBundlerChain(async (chain, { CHAIN_ID, target, HtmlPlugin }) => {
33
- const config = api.getNormalizedConfig();
34
- if (!config.output.assetsRetry || (0, builder_shared_1.isHtmlDisabled)(config, target)) {
35
- return;
36
- }
37
- const { AssetsRetryPlugin } = await Promise.resolve().then(() => __importStar(require('@modern-js/builder-shared')));
38
- const distDir = (0, builder_shared_1.getDistPath)(config.output, 'js');
39
- const { assetsRetry = {} } = config.output;
40
- // assetsRetry.crossOrigin should be same as html.crossorigin by default
41
- if (assetsRetry.crossOrigin === undefined) {
42
- assetsRetry.crossOrigin = config.html.crossorigin;
43
- }
44
- chain.plugin(CHAIN_ID.PLUGIN.ASSETS_RETRY).use(AssetsRetryPlugin, [
45
- {
46
- ...assetsRetry,
47
- distDir,
48
- HtmlPlugin,
49
- },
50
- ]);
51
- });
52
- },
53
- };
14
+ return {
15
+ name: "builder-plugin-assets-retry",
16
+ setup(api) {
17
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, target, HtmlPlugin }) => {
18
+ const config = api.getNormalizedConfig();
19
+ if (!config.output.assetsRetry || (0, _buildershared.isHtmlDisabled)(config, target)) {
20
+ return;
21
+ }
22
+ const { AssetsRetryPlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared")));
23
+ const distDir = (0, _buildershared.getDistPath)(config.output, "js");
24
+ const { assetsRetry = {} } = config.output;
25
+ if (assetsRetry.crossOrigin === void 0) {
26
+ assetsRetry.crossOrigin = config.html.crossorigin;
27
+ }
28
+ chain.plugin(CHAIN_ID.PLUGIN.ASSETS_RETRY).use(AssetsRetryPlugin, [
29
+ {
30
+ ...assetsRetry,
31
+ distDir,
32
+ HtmlPlugin
33
+ }
34
+ ]);
35
+ });
36
+ }
37
+ };
54
38
  }
55
- exports.builderPluginAssetsRetry = builderPluginAssetsRetry;
@@ -1,2 +1,2 @@
1
1
  import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
- export declare function builderPluginBundleAnalyzer(): DefaultBuilderPlugin;
2
+ export declare function builderPluginBundleAnalyzer(): DefaultBuilderPlugin;
@@ -1,54 +1,33 @@
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, "builderPluginBundleAnalyzer", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return builderPluginBundleAnalyzer;
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.builderPluginBundleAnalyzer = void 0;
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
27
12
  function builderPluginBundleAnalyzer() {
28
- return {
29
- name: 'builder-plugin-bundle-analyzer',
30
- setup(api) {
31
- api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
32
- const config = api.getNormalizedConfig();
33
- // There are two ways to open the bundle analyzer:
34
- // 1. Set environment variable `BUNDLE_ANALYZE`
35
- // 2. Set performance.bundleAnalyze config
36
- if (!process.env.BUNDLE_ANALYZE && !config.performance.bundleAnalyze) {
37
- return;
38
- }
39
- const { default: BundleAnalyzer } = await Promise.resolve().then(() => __importStar(require('@modern-js/builder-shared/webpack-bundle-analyzer')));
40
- chain
41
- .plugin(CHAIN_ID.PLUGIN.BUNDLE_ANALYZER)
42
- .use(BundleAnalyzer.BundleAnalyzerPlugin, [
43
- {
44
- analyzerMode: 'static',
45
- openAnalyzer: false,
46
- reportFilename: `report-${target}.html`,
47
- ...(config.performance.bundleAnalyze || {}),
48
- },
49
- ]);
50
- });
51
- },
52
- };
13
+ return {
14
+ name: "builder-plugin-bundle-analyzer",
15
+ setup(api) {
16
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
17
+ const config = api.getNormalizedConfig();
18
+ if (!process.env.BUNDLE_ANALYZE && !config.performance.bundleAnalyze) {
19
+ return;
20
+ }
21
+ const { default: BundleAnalyzer } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared/webpack-bundle-analyzer")));
22
+ chain.plugin(CHAIN_ID.PLUGIN.BUNDLE_ANALYZER).use(BundleAnalyzer.BundleAnalyzerPlugin, [
23
+ {
24
+ analyzerMode: "static",
25
+ openAnalyzer: false,
26
+ reportFilename: `report-${target}.html`,
27
+ ...config.performance.bundleAnalyze || {}
28
+ }
29
+ ]);
30
+ });
31
+ }
32
+ };
53
33
  }
54
- exports.builderPluginBundleAnalyzer = builderPluginBundleAnalyzer;
@@ -1,2 +1,2 @@
1
1
  import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
- export declare const builderPluginCache: () => DefaultBuilderPlugin;
2
+ export declare const builderPluginCache: () => DefaultBuilderPlugin;