@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # @modern-js/builder
2
2
 
3
+ ## 2.28.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7d966a1: feat(builder): source code build feature support project reference by adding tsCheck configuration
8
+ feat(builder): 源码构建增加 tsCheck 配置支持 project reference 的情况
9
+
10
+ ### Patch Changes
11
+
12
+ - fb93353: fix(builder): support source code build when ts-loader enable
13
+ fix(builder): 在 ts-loader 开启的时候支持源码构建
14
+ - 362416f: feat(builder): support import Node.js addons when target is node
15
+
16
+ feat(builder): 支持在 target 为 node 时引用 Node.js addons
17
+
18
+ - 820bfe9: feat(builder): add checkSyntax.ecmaVersion option
19
+
20
+ feat(builder): 新增 checkSyntax.ecmaVersion 选项
21
+
22
+ - Updated dependencies [6400d98]
23
+ - Updated dependencies [362416f]
24
+ - Updated dependencies [aa0c0c3]
25
+ - Updated dependencies [9301e46]
26
+ - Updated dependencies [00b58a7]
27
+ - Updated dependencies [820bfe9]
28
+ - Updated dependencies [d3e52e4]
29
+ - @modern-js/builder-shared@2.28.0
30
+ - @modern-js/utils@2.28.0
31
+ - @modern-js/monorepo-utils@2.28.0
32
+
33
+ ## 2.27.0
34
+
35
+ ### Patch Changes
36
+
37
+ - 8322a51: chore: migrate packages from tsc to module-lib build
38
+
39
+ chore: 将使用 tsc 的包迁移到 module-lib 构建
40
+
41
+ - Updated dependencies [645e111]
42
+ - Updated dependencies [91d14b8]
43
+ - Updated dependencies [8322a51]
44
+ - Updated dependencies [d9080ed]
45
+ - Updated dependencies [67d0b0c]
46
+ - Updated dependencies [3f79dd7]
47
+ - Updated dependencies [6d7104d]
48
+ - @modern-js/builder-shared@2.27.0
49
+ - @modern-js/utils@2.27.0
50
+ - @modern-js/monorepo-utils@2.27.0
51
+
3
52
  ## 2.26.0
4
53
 
5
54
  ### 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,56 @@
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");
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");
5
21
  const builderPluginAntd = () => ({
6
- name: `builder-plugin-antd`,
7
- 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;
14
- }
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
- },
22
+ name: `builder-plugin-antd`,
23
+ setup(api) {
24
+ api.modifyBuilderConfig((builderConfig) => {
25
+ var _builderConfig_source_transformImport;
26
+ var _builderConfig;
27
+ var _source;
28
+ (_source = (_builderConfig = builderConfig).source) !== null && _source !== void 0 ? _source : _builderConfig.source = {};
29
+ 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"))) {
30
+ return;
31
+ }
32
+ const antdMajorVersion = (0, _utils.getAntdMajorVersion)(api.context.rootPath);
33
+ if (antdMajorVersion && antdMajorVersion < 5) {
34
+ var _builderConfig1;
35
+ var _source1;
36
+ (_source1 = (_builderConfig1 = builderConfig).source) !== null && _source1 !== void 0 ? _source1 : _builderConfig1.source = {};
37
+ builderConfig.source.transformImport = [
38
+ ...builderConfig.source.transformImport || [],
39
+ {
40
+ libraryName: "antd",
41
+ libraryDirectory: useSSR(api.context.target) ? "lib" : "es",
42
+ style: true
43
+ }
44
+ ];
45
+ }
46
+ });
47
+ }
31
48
  });
32
- exports.builderPluginAntd = builderPluginAntd;
33
49
  function useSSR(target) {
34
- return (Array.isArray(target) ? target : [target]).some(item => ['node', 'service-worker'].includes(item));
50
+ return (Array.isArray(target) ? target : [
51
+ target
52
+ ]).some((item) => [
53
+ "node",
54
+ "service-worker"
55
+ ].includes(item));
35
56
  }
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,45 @@
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");
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");
6
13
  const builderPluginArco = () => ({
7
- name: `builder-plugin-arco`,
8
- 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;
14
+ name: `builder-plugin-arco`,
15
+ setup(api) {
16
+ const ARCO_NAME = "@arco-design/web-react";
17
+ const ARCO_ICON = `${ARCO_NAME}/icon`;
18
+ api.modifyBuilderConfig((builderConfig) => {
19
+ var _transformImport, _transformImport1;
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 = 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 (!((_transformImport1 = transformImport) === null || _transformImport1 === void 0 ? void 0 : _transformImport1.some((item) => item.libraryName === ARCO_ICON))) {
35
+ transformImport.push({
36
+ libraryName: ARCO_ICON,
37
+ libraryDirectory: isUseSSR ? "react-icon-cjs" : "react-icon",
38
+ camelToDashComponentName: false
35
39
  });
36
- },
40
+ }
41
+ (_builderConfig = builderConfig).source || (_builderConfig.source = {});
42
+ builderConfig.source.transformImport = transformImport;
43
+ });
44
+ }
37
45
  });
38
- exports.builderPluginArco = builderPluginArco;
@@ -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;