@umijs/bundler-webpack 4.0.5 → 4.0.8

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 (67) hide show
  1. package/{dist → client}/client/client.d.ts +0 -0
  2. package/client/client/client.js +172 -192
  3. package/client/constants.d.ts +15 -0
  4. package/client/constants.js +28 -19
  5. package/client/utils/formatWebpackMessages.d.ts +12 -0
  6. package/client/utils/formatWebpackMessages.js +68 -86
  7. package/dist/build.d.ts +1 -1
  8. package/dist/build.js +105 -61
  9. package/dist/cli.js +77 -69
  10. package/dist/config/_sampleFeature.js +33 -9
  11. package/dist/config/assetRules.js +45 -36
  12. package/dist/config/bundleAnalyzerPlugin.js +39 -17
  13. package/dist/config/compressPlugin.js +113 -95
  14. package/dist/config/config.d.ts +1 -0
  15. package/dist/config/config.js +204 -215
  16. package/dist/config/copyPlugin.js +58 -33
  17. package/dist/config/cssRules.js +136 -131
  18. package/dist/config/definePlugin.d.ts +1 -0
  19. package/dist/config/definePlugin.js +71 -31
  20. package/dist/config/detectDeadCode.js +120 -108
  21. package/dist/config/detectDeadCodePlugin.js +78 -63
  22. package/dist/config/fastRefreshPlugin.js +39 -20
  23. package/dist/config/forkTSCheckerPlugin.js +38 -19
  24. package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
  25. package/dist/config/ignorePlugin.js +38 -14
  26. package/dist/config/javaScriptRules.js +146 -173
  27. package/dist/config/manifestPlugin.js +51 -15
  28. package/dist/config/miniCSSExtractPlugin.js +42 -22
  29. package/dist/config/nodePolyfill.js +65 -26
  30. package/dist/config/nodePrefixPlugin.js +36 -12
  31. package/dist/config/progressPlugin.js +37 -13
  32. package/dist/config/purgecssWebpackPlugin.js +41 -19
  33. package/dist/config/speedMeasureWebpackPlugin.js +41 -20
  34. package/dist/config/ssrPlugin.js +83 -63
  35. package/dist/config/svgRules.js +74 -46
  36. package/dist/constants.js +57 -22
  37. package/dist/dev.d.ts +1 -1
  38. package/dist/dev.js +170 -129
  39. package/dist/index.d.ts +0 -2
  40. package/dist/index.js +22 -35
  41. package/dist/loader/svgr.js +73 -54
  42. package/dist/loader/swc.js +110 -69
  43. package/dist/parcelCSS.d.ts +2 -0
  44. package/dist/parcelCSS.js +32 -0
  45. package/dist/plugins/ProgressPlugin.js +66 -43
  46. package/dist/plugins/RuntimePublicPathPlugin.js +42 -23
  47. package/dist/plugins/_SamplePlugin.js +39 -14
  48. package/dist/requireHook.js +37 -27
  49. package/dist/schema.js +119 -95
  50. package/dist/server/server.d.ts +0 -1
  51. package/dist/server/server.js +214 -184
  52. package/dist/server/ws.d.ts +0 -2
  53. package/dist/server/ws.js +63 -38
  54. package/dist/swcPlugins/autoCSSModules.js +50 -31
  55. package/dist/swcPlugins/changeImportFromString.js +31 -9
  56. package/dist/swcPlugins/lockCoreJS.js +44 -20
  57. package/dist/types.js +61 -30
  58. package/dist/utils/browsersList.js +31 -8
  59. package/dist/utils/depMatch.js +63 -39
  60. package/dist/utils/formatWebpackMessages.js +93 -91
  61. package/dist/utils/getEsBuildTarget.js +32 -10
  62. package/package.json +9 -11
  63. package/compiled/fork-ts-checker-webpack-plugin/LICENSE +0 -21
  64. package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
  65. package/compiled/fork-ts-checker-webpack-plugin/index.js +0 -42
  66. package/compiled/fork-ts-checker-webpack-plugin/package.json +0 -1
  67. package/dist/client/client.js +0 -245
package/dist/build.d.ts CHANGED
@@ -15,6 +15,6 @@ declare type IOpts = {
15
15
  extraBabelPlugins?: any[];
16
16
  extraBabelPresets?: any[];
17
17
  clean?: boolean;
18
- } & Pick<IConfigOpts, 'cache'>;
18
+ } & Pick<IConfigOpts, 'cache' | 'pkg'>;
19
19
  export declare function build(opts: IOpts): Promise<webpack.Stats>;
20
20
  export {};
package/dist/build.js CHANGED
@@ -1,66 +1,110 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
4
22
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.build = void 0;
7
- const utils_1 = require("@umijs/utils");
8
- const webpack_1 = __importDefault(require("../compiled/webpack"));
9
- const config_1 = require("./config/config");
10
- const types_1 = require("./types");
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+
39
+ // build.ts
40
+ var build_exports = {};
41
+ __export(build_exports, {
42
+ build: () => build
43
+ });
44
+ module.exports = __toCommonJS(build_exports);
45
+ var import_utils = require("@umijs/utils");
46
+ var import_path = require("path");
47
+ var import_webpack = __toESM(require("../compiled/webpack"));
48
+ var import_config = require("./config/config");
49
+ var import_types = require("./types");
11
50
  async function build(opts) {
12
- const webpackConfig = await (0, config_1.getConfig)({
13
- cwd: opts.cwd,
14
- rootDir: opts.rootDir,
15
- env: types_1.Env.production,
16
- entry: opts.entry,
17
- userConfig: opts.config,
18
- analyze: process.env.ANALYZE,
19
- babelPreset: opts.babelPreset,
20
- extraBabelPlugins: [
21
- ...(opts.beforeBabelPlugins || []),
22
- ...(opts.extraBabelPlugins || []),
23
- ],
24
- extraBabelPresets: [
25
- ...(opts.beforeBabelPresets || []),
26
- ...(opts.extraBabelPresets || []),
27
- ],
28
- extraBabelIncludes: opts.config.extraBabelIncludes,
29
- chainWebpack: opts.chainWebpack,
30
- modifyWebpackConfig: opts.modifyWebpackConfig,
31
- cache: opts.cache,
32
- });
33
- let isFirstCompile = true;
34
- return new Promise((resolve, reject) => {
35
- if (opts.clean) {
36
- utils_1.rimraf.sync(webpackConfig.output.path);
51
+ const cacheDirectoryPath = (0, import_path.resolve)(opts.rootDir || opts.cwd, opts.config.cacheDirectoryPath || "node_modules/.cache");
52
+ const webpackConfig = await (0, import_config.getConfig)({
53
+ cwd: opts.cwd,
54
+ rootDir: opts.rootDir,
55
+ env: import_types.Env.production,
56
+ entry: opts.entry,
57
+ userConfig: opts.config,
58
+ analyze: process.env.ANALYZE,
59
+ babelPreset: opts.babelPreset,
60
+ extraBabelPlugins: [
61
+ ...opts.beforeBabelPlugins || [],
62
+ ...opts.extraBabelPlugins || []
63
+ ],
64
+ extraBabelPresets: [
65
+ ...opts.beforeBabelPresets || [],
66
+ ...opts.extraBabelPresets || []
67
+ ],
68
+ extraBabelIncludes: opts.config.extraBabelIncludes,
69
+ chainWebpack: opts.chainWebpack,
70
+ modifyWebpackConfig: opts.modifyWebpackConfig,
71
+ cache: opts.cache ? __spreadProps(__spreadValues({}, opts.cache), {
72
+ cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "bundler-webpack")
73
+ }) : void 0,
74
+ pkg: opts.pkg
75
+ });
76
+ let isFirstCompile = true;
77
+ return new Promise((resolve2, reject) => {
78
+ if (opts.clean) {
79
+ import_utils.rimraf.sync(webpackConfig.output.path);
80
+ }
81
+ const compiler = (0, import_webpack.default)(webpackConfig);
82
+ compiler.run((err, stats) => {
83
+ var _a;
84
+ (_a = opts.onBuildComplete) == null ? void 0 : _a.call(opts, {
85
+ err,
86
+ stats,
87
+ isFirstCompile,
88
+ time: stats ? stats.endTime - stats.startTime : null
89
+ });
90
+ isFirstCompile = false;
91
+ if (err || (stats == null ? void 0 : stats.hasErrors())) {
92
+ if (err) {
93
+ reject(err);
94
+ }
95
+ if (stats) {
96
+ const errorMsg = stats.toString("errors-only");
97
+ reject(new Error(errorMsg));
37
98
  }
38
- const compiler = (0, webpack_1.default)(webpackConfig);
39
- compiler.run((err, stats) => {
40
- var _a;
41
- (_a = opts.onBuildComplete) === null || _a === void 0 ? void 0 : _a.call(opts, {
42
- err,
43
- stats,
44
- isFirstCompile,
45
- time: stats ? stats.endTime - stats.startTime : null,
46
- });
47
- isFirstCompile = false;
48
- if (err || (stats === null || stats === void 0 ? void 0 : stats.hasErrors())) {
49
- if (err) {
50
- // console.error(err);
51
- reject(err);
52
- }
53
- if (stats) {
54
- const errorMsg = stats.toString('errors-only');
55
- // console.error(errorMsg);
56
- reject(new Error(errorMsg));
57
- }
58
- }
59
- else {
60
- resolve(stats);
61
- }
62
- compiler.close(() => { });
63
- });
99
+ } else {
100
+ resolve2(stats);
101
+ }
102
+ compiler.close(() => {
103
+ });
64
104
  });
105
+ });
65
106
  }
66
- exports.build = build;
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ build
110
+ });
package/dist/cli.js CHANGED
@@ -1,81 +1,89 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
4
14
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const esbuild_1 = __importDefault(require("@umijs/bundler-utils/compiled/esbuild"));
7
- const utils_1 = require("@umijs/utils");
8
- const assert_1 = __importDefault(require("assert"));
9
- const fs_1 = require("fs");
10
- const path_1 = require("path");
11
- const build_1 = require("./build");
12
- const dev_1 = require("./dev");
13
- const args = (0, utils_1.yParser)(process.argv.slice(2), {});
14
- const command = args._[0];
15
- const cwd = process.cwd();
16
- const entry = (0, utils_1.tryPaths)([
17
- (0, path_1.join)(cwd, 'src/index.tsx'),
18
- (0, path_1.join)(cwd, 'src/index.ts'),
19
- (0, path_1.join)(cwd, 'index.tsx'),
20
- (0, path_1.join)(cwd, 'index.ts'),
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
16
+
17
+ // cli.ts
18
+ var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
19
+ var import_utils = require("@umijs/utils");
20
+ var import_assert = __toESM(require("assert"));
21
+ var import_fs = require("fs");
22
+ var import_path = require("path");
23
+ var import_build = require("./build");
24
+ var import_dev = require("./dev");
25
+ var args = (0, import_utils.yParser)(process.argv.slice(2), {});
26
+ var command = args._[0];
27
+ var cwd = process.cwd();
28
+ var entry = (0, import_utils.tryPaths)([
29
+ (0, import_path.join)(cwd, "src/index.tsx"),
30
+ (0, import_path.join)(cwd, "src/index.ts"),
31
+ (0, import_path.join)(cwd, "index.tsx"),
32
+ (0, import_path.join)(cwd, "index.ts")
21
33
  ]);
22
- let config = {};
23
- const configFile = (0, path_1.join)(cwd, args.config || 'config.ts');
24
- utils_1.register.register({
25
- implementor: esbuild_1.default,
34
+ var config = {};
35
+ var configFile = (0, import_path.join)(cwd, args.config || "config.ts");
36
+ import_utils.register.register({
37
+ implementor: import_esbuild.default
26
38
  });
27
- utils_1.register.clearFiles();
28
- if ((0, fs_1.existsSync)(configFile)) {
29
- require('./requireHook');
30
- config = require(configFile).default;
39
+ import_utils.register.clearFiles();
40
+ if ((0, import_fs.existsSync)(configFile)) {
41
+ require("./requireHook");
42
+ config = require(configFile).default;
31
43
  }
32
44
  Object.assign(config, args);
33
- if (command === 'build') {
34
- (async () => {
35
- process.env.NODE_ENV = 'production';
36
- (0, assert_1.default)(entry, `Build failed: entry not found.`);
37
- try {
38
- await (0, build_1.build)({
39
- config,
40
- cwd,
41
- entry: {
42
- [getEntryKey(entry)]: entry,
43
- },
44
- });
45
+ if (command === "build") {
46
+ (async () => {
47
+ process.env.NODE_ENV = "production";
48
+ (0, import_assert.default)(entry, `Build failed: entry not found.`);
49
+ try {
50
+ await (0, import_build.build)({
51
+ config,
52
+ cwd,
53
+ entry: {
54
+ [getEntryKey(entry)]: entry
45
55
  }
46
- catch (e) {
47
- console.error(e);
56
+ });
57
+ } catch (e) {
58
+ console.error(e);
59
+ }
60
+ })();
61
+ } else if (command === "dev") {
62
+ (async () => {
63
+ process.env.NODE_ENV = "development";
64
+ try {
65
+ (0, import_assert.default)(entry, `Build failed: entry not found.`);
66
+ await (0, import_dev.dev)({
67
+ config,
68
+ cwd,
69
+ port: process.env.PORT,
70
+ entry: {
71
+ [getEntryKey(entry)]: entry
72
+ },
73
+ cache: {
74
+ buildDependencies: [].filter(Boolean)
48
75
  }
49
- })();
50
- }
51
- else if (command === 'dev') {
52
- (async () => {
53
- process.env.NODE_ENV = 'development';
54
- try {
55
- (0, assert_1.default)(entry, `Build failed: entry not found.`);
56
- await (0, dev_1.dev)({
57
- config,
58
- cwd,
59
- port: process.env.PORT,
60
- entry: {
61
- [getEntryKey(entry)]: entry,
62
- },
63
- cache: {
64
- buildDependencies: [].filter(Boolean),
65
- },
66
- });
67
- }
68
- catch (e) {
69
- console.error(e);
70
- }
71
- })();
72
- }
73
- else {
74
- error(`Unsupported command ${command}.`);
76
+ });
77
+ } catch (e) {
78
+ console.error(e);
79
+ }
80
+ })();
81
+ } else {
82
+ error(`Unsupported command ${command}.`);
75
83
  }
76
84
  function error(msg) {
77
- console.error(utils_1.chalk.red(msg));
85
+ console.error(import_utils.chalk.red(msg));
78
86
  }
79
87
  function getEntryKey(path) {
80
- return (0, path_1.basename)(path, (0, path_1.extname)(path));
88
+ return (0, import_path.basename)(path, (0, import_path.extname)(path));
81
89
  }
@@ -1,11 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addSampleFeature = void 0;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // _sampleFeature.ts
20
+ var sampleFeature_exports = {};
21
+ __export(sampleFeature_exports, {
22
+ addSampleFeature: () => addSampleFeature
23
+ });
24
+ module.exports = __toCommonJS(sampleFeature_exports);
4
25
  async function addSampleFeature(opts) {
5
- const { config, userConfig, cwd, env } = opts;
6
- config;
7
- userConfig;
8
- cwd;
9
- env;
26
+ const { config, userConfig, cwd, env } = opts;
27
+ config;
28
+ userConfig;
29
+ cwd;
30
+ env;
10
31
  }
11
- exports.addSampleFeature = addSampleFeature;
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ addSampleFeature
35
+ });
@@ -1,39 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addAssetRules = void 0;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // assetRules.ts
20
+ var assetRules_exports = {};
21
+ __export(assetRules_exports, {
22
+ addAssetRules: () => addAssetRules
23
+ });
24
+ module.exports = __toCommonJS(assetRules_exports);
4
25
  async function addAssetRules(opts) {
5
- const { config, userConfig } = opts;
6
- const inlineLimit = parseInt(userConfig.inlineLimit || '10000', 10);
7
- const rule = config.module.rule('asset');
8
- rule
9
- .oneOf('avif')
10
- .test(/\.avif$/)
11
- .type('asset')
12
- .mimetype('image/avif')
13
- .parser({
14
- dataUrlCondition: {
15
- maxSize: inlineLimit,
16
- },
17
- });
18
- rule
19
- .oneOf('image')
20
- .test(/\.(bmp|gif|jpg|jpeg|png)$/)
21
- .type('asset')
22
- .parser({
23
- dataUrlCondition: {
24
- maxSize: inlineLimit,
25
- },
26
- });
27
- const fallback = rule
28
- .oneOf('fallback')
29
- .exclude.add(/^$/) /* handle data: resources */
30
- .add(/\.(js|mjs|jsx|ts|tsx)$/)
31
- .add(/\.(css|less|sass|scss|stylus)$/)
32
- .add(/\.html$/)
33
- .add(/\.json$/);
34
- if (userConfig.mdx) {
35
- fallback.add(/\.mdx?$/);
26
+ const { config, userConfig } = opts;
27
+ const inlineLimit = parseInt(userConfig.inlineLimit || "10000", 10);
28
+ const rule = config.module.rule("asset");
29
+ rule.oneOf("avif").test(/\.avif$/).type("asset").mimetype("image/avif").parser({
30
+ dataUrlCondition: {
31
+ maxSize: inlineLimit
36
32
  }
37
- fallback.end().type('asset/resource');
33
+ });
34
+ rule.oneOf("image").test(/\.(bmp|gif|jpg|jpeg|png)$/).type("asset").parser({
35
+ dataUrlCondition: {
36
+ maxSize: inlineLimit
37
+ }
38
+ });
39
+ const fallback = rule.oneOf("fallback").exclude.add(/^$/).add(/\.(js|mjs|jsx|ts|tsx)$/).add(/\.(css|less|sass|scss|stylus)$/).add(/\.html$/).add(/\.json$/);
40
+ if (userConfig.mdx) {
41
+ fallback.add(/\.mdx?$/);
42
+ }
43
+ fallback.end().type("asset/resource");
38
44
  }
39
- exports.addAssetRules = addAssetRules;
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ addAssetRules
48
+ });
@@ -1,19 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addBundleAnalyzerPlugin = void 0;
4
- // @ts-ignore
5
- const webpack_bundle_analyzer_1 = require("@umijs/bundler-webpack/compiled/webpack-bundle-analyzer");
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // bundleAnalyzerPlugin.ts
20
+ var bundleAnalyzerPlugin_exports = {};
21
+ __export(bundleAnalyzerPlugin_exports, {
22
+ addBundleAnalyzerPlugin: () => addBundleAnalyzerPlugin
23
+ });
24
+ module.exports = __toCommonJS(bundleAnalyzerPlugin_exports);
25
+ var import_webpack_bundle_analyzer = require("@umijs/bundler-webpack/compiled/webpack-bundle-analyzer");
6
26
  async function addBundleAnalyzerPlugin(opts) {
7
- const { config } = opts;
8
- config.plugin('webpack-bundle-analyzer').use(webpack_bundle_analyzer_1.BundleAnalyzerPlugin, [
9
- // https://github.com/webpack-contrib/webpack-bundle-analyzer
10
- {
11
- analyzerMode: 'server',
12
- analyzerPort: process.env.ANALYZE_PORT || 8888,
13
- openAnalyzer: false,
14
- logLevel: 'info',
15
- defaultSizes: 'parsed',
16
- },
17
- ]);
27
+ const { config } = opts;
28
+ config.plugin("webpack-bundle-analyzer").use(import_webpack_bundle_analyzer.BundleAnalyzerPlugin, [
29
+ {
30
+ analyzerMode: "server",
31
+ analyzerPort: process.env.ANALYZE_PORT || 8888,
32
+ openAnalyzer: false,
33
+ logLevel: "info",
34
+ defaultSizes: "parsed"
35
+ }
36
+ ]);
18
37
  }
19
- exports.addBundleAnalyzerPlugin = addBundleAnalyzerPlugin;
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ addBundleAnalyzerPlugin
41
+ });