@umijs/bundler-webpack 4.0.0-canary.20220718.2 → 4.0.0-canary.20220729.1

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 (154) hide show
  1. package/client/client/client.d.ts +1 -0
  2. package/client/client/client.js +295 -194
  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 -2
  8. package/dist/build.js +105 -68
  9. package/dist/cli.d.ts +0 -1
  10. package/dist/cli.js +77 -69
  11. package/dist/config/_sampleFeature.d.ts +0 -1
  12. package/dist/config/_sampleFeature.js +33 -9
  13. package/dist/config/assetRules.d.ts +0 -1
  14. package/dist/config/assetRules.js +45 -36
  15. package/dist/config/bundleAnalyzerPlugin.d.ts +0 -1
  16. package/dist/config/bundleAnalyzerPlugin.js +39 -17
  17. package/dist/config/compressPlugin.d.ts +0 -1
  18. package/dist/config/compressPlugin.js +113 -95
  19. package/dist/config/config.d.ts +1 -1
  20. package/dist/config/config.js +204 -218
  21. package/dist/config/copyPlugin.d.ts +0 -1
  22. package/dist/config/copyPlugin.js +59 -40
  23. package/dist/config/cssRules.d.ts +0 -1
  24. package/dist/config/cssRules.js +136 -131
  25. package/dist/config/definePlugin.d.ts +0 -1
  26. package/dist/config/definePlugin.js +71 -35
  27. package/dist/config/detectDeadCode.d.ts +0 -1
  28. package/dist/config/detectDeadCode.js +120 -108
  29. package/dist/config/detectDeadCodePlugin.d.ts +0 -1
  30. package/dist/config/detectDeadCodePlugin.js +78 -63
  31. package/dist/config/fastRefreshPlugin.d.ts +0 -1
  32. package/dist/config/fastRefreshPlugin.js +39 -20
  33. package/dist/config/forkTSCheckerPlugin.d.ts +0 -1
  34. package/dist/config/forkTSCheckerPlugin.js +38 -18
  35. package/dist/config/harmonyLinkingErrorPlugin.d.ts +0 -1
  36. package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
  37. package/dist/config/ignorePlugin.d.ts +0 -1
  38. package/dist/config/ignorePlugin.js +38 -14
  39. package/dist/config/javaScriptRules.d.ts +0 -1
  40. package/dist/config/javaScriptRules.js +147 -175
  41. package/dist/config/manifestPlugin.d.ts +0 -1
  42. package/dist/config/manifestPlugin.js +51 -15
  43. package/dist/config/miniCSSExtractPlugin.d.ts +0 -1
  44. package/dist/config/miniCSSExtractPlugin.js +42 -22
  45. package/dist/config/nodePolyfill.d.ts +0 -1
  46. package/dist/config/nodePolyfill.js +65 -26
  47. package/dist/config/nodePrefixPlugin.d.ts +0 -1
  48. package/dist/config/nodePrefixPlugin.js +36 -12
  49. package/dist/config/progressPlugin.d.ts +0 -1
  50. package/dist/config/progressPlugin.js +37 -13
  51. package/dist/config/purgecssWebpackPlugin.d.ts +0 -1
  52. package/dist/config/purgecssWebpackPlugin.js +41 -19
  53. package/dist/config/speedMeasureWebpackPlugin.d.ts +0 -1
  54. package/dist/config/speedMeasureWebpackPlugin.js +41 -20
  55. package/dist/config/ssrPlugin.d.ts +0 -1
  56. package/dist/config/ssrPlugin.js +83 -63
  57. package/dist/config/svgRules.d.ts +0 -1
  58. package/dist/config/svgRules.js +74 -46
  59. package/dist/constants.d.ts +0 -1
  60. package/dist/constants.js +57 -22
  61. package/dist/dev.d.ts +1 -2
  62. package/dist/dev.js +174 -135
  63. package/dist/index.d.ts +0 -1
  64. package/dist/index.js +22 -20
  65. package/dist/loader/svgr.d.ts +0 -1
  66. package/dist/loader/svgr.js +73 -54
  67. package/dist/loader/swc.d.ts +0 -1
  68. package/dist/loader/swc.js +110 -69
  69. package/dist/parcelCSS.d.ts +0 -1
  70. package/dist/parcelCSS.js +31 -27
  71. package/dist/plugins/ProgressPlugin.d.ts +0 -1
  72. package/dist/plugins/ProgressPlugin.js +66 -43
  73. package/dist/plugins/RuntimePublicPathPlugin.d.ts +0 -1
  74. package/dist/plugins/RuntimePublicPathPlugin.js +42 -25
  75. package/dist/plugins/_SamplePlugin.d.ts +0 -1
  76. package/dist/plugins/_SamplePlugin.js +39 -14
  77. package/dist/requireHook.d.ts +0 -1
  78. package/dist/requireHook.js +37 -27
  79. package/dist/schema.d.ts +0 -1
  80. package/dist/schema.js +123 -97
  81. package/dist/server/server.d.ts +0 -2
  82. package/dist/server/server.js +214 -184
  83. package/dist/server/ws.d.ts +0 -3
  84. package/dist/server/ws.js +63 -38
  85. package/dist/swcPlugins/autoCSSModules.d.ts +0 -1
  86. package/dist/swcPlugins/autoCSSModules.js +50 -31
  87. package/dist/swcPlugins/changeImportFromString.d.ts +0 -1
  88. package/dist/swcPlugins/changeImportFromString.js +31 -9
  89. package/dist/swcPlugins/lockCoreJS.d.ts +0 -1
  90. package/dist/swcPlugins/lockCoreJS.js +44 -20
  91. package/dist/types.d.ts +2 -2
  92. package/dist/types.js +61 -30
  93. package/dist/utils/browsersList.d.ts +0 -1
  94. package/dist/utils/browsersList.js +31 -8
  95. package/dist/utils/depMatch.d.ts +0 -1
  96. package/dist/utils/depMatch.js +63 -39
  97. package/dist/utils/formatWebpackMessages.d.ts +0 -1
  98. package/dist/utils/formatWebpackMessages.js +93 -91
  99. package/dist/utils/getEsBuildTarget.d.ts +0 -1
  100. package/dist/utils/getEsBuildTarget.js +32 -10
  101. package/package.json +10 -15
  102. package/compiled/react-refresh/LICENSE +0 -21
  103. package/compiled/react-refresh/index.js +0 -21
  104. package/compiled/react-refresh/package.json +0 -1
  105. package/dist/build.d.ts.map +0 -1
  106. package/dist/cli.d.ts.map +0 -1
  107. package/dist/client/client.d.ts +0 -2
  108. package/dist/client/client.d.ts.map +0 -1
  109. package/dist/client/client.js +0 -245
  110. package/dist/config/_sampleFeature.d.ts.map +0 -1
  111. package/dist/config/assetRules.d.ts.map +0 -1
  112. package/dist/config/bundleAnalyzerPlugin.d.ts.map +0 -1
  113. package/dist/config/compressPlugin.d.ts.map +0 -1
  114. package/dist/config/config.d.ts.map +0 -1
  115. package/dist/config/copyPlugin.d.ts.map +0 -1
  116. package/dist/config/cssRules.d.ts.map +0 -1
  117. package/dist/config/definePlugin.d.ts.map +0 -1
  118. package/dist/config/detectDeadCode.d.ts.map +0 -1
  119. package/dist/config/detectDeadCodePlugin.d.ts.map +0 -1
  120. package/dist/config/fastRefreshPlugin.d.ts.map +0 -1
  121. package/dist/config/forkTSCheckerPlugin.d.ts.map +0 -1
  122. package/dist/config/harmonyLinkingErrorPlugin.d.ts.map +0 -1
  123. package/dist/config/ignorePlugin.d.ts.map +0 -1
  124. package/dist/config/javaScriptRules.d.ts.map +0 -1
  125. package/dist/config/manifestPlugin.d.ts.map +0 -1
  126. package/dist/config/miniCSSExtractPlugin.d.ts.map +0 -1
  127. package/dist/config/nodePolyfill.d.ts.map +0 -1
  128. package/dist/config/nodePrefixPlugin.d.ts.map +0 -1
  129. package/dist/config/progressPlugin.d.ts.map +0 -1
  130. package/dist/config/purgecssWebpackPlugin.d.ts.map +0 -1
  131. package/dist/config/speedMeasureWebpackPlugin.d.ts.map +0 -1
  132. package/dist/config/ssrPlugin.d.ts.map +0 -1
  133. package/dist/config/svgRules.d.ts.map +0 -1
  134. package/dist/constants.d.ts.map +0 -1
  135. package/dist/dev.d.ts.map +0 -1
  136. package/dist/index.d.ts.map +0 -1
  137. package/dist/loader/svgr.d.ts.map +0 -1
  138. package/dist/loader/swc.d.ts.map +0 -1
  139. package/dist/parcelCSS.d.ts.map +0 -1
  140. package/dist/plugins/ProgressPlugin.d.ts.map +0 -1
  141. package/dist/plugins/RuntimePublicPathPlugin.d.ts.map +0 -1
  142. package/dist/plugins/_SamplePlugin.d.ts.map +0 -1
  143. package/dist/requireHook.d.ts.map +0 -1
  144. package/dist/schema.d.ts.map +0 -1
  145. package/dist/server/server.d.ts.map +0 -1
  146. package/dist/server/ws.d.ts.map +0 -1
  147. package/dist/swcPlugins/autoCSSModules.d.ts.map +0 -1
  148. package/dist/swcPlugins/changeImportFromString.d.ts.map +0 -1
  149. package/dist/swcPlugins/lockCoreJS.d.ts.map +0 -1
  150. package/dist/types.d.ts.map +0 -1
  151. package/dist/utils/browsersList.d.ts.map +0 -1
  152. package/dist/utils/depMatch.d.ts.map +0 -1
  153. package/dist/utils/formatWebpackMessages.d.ts.map +0 -1
  154. package/dist/utils/getEsBuildTarget.d.ts.map +0 -1
@@ -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
+ // src/config/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
+ });
@@ -8,4 +8,3 @@ interface IOpts {
8
8
  }
9
9
  export declare function addBundleAnalyzerPlugin(opts: IOpts): Promise<void>;
10
10
  export {};
11
- //# sourceMappingURL=bundleAnalyzerPlugin.d.ts.map
@@ -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
+ // src/config/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
+ });
@@ -8,4 +8,3 @@ interface IOpts {
8
8
  }
9
9
  export declare function addCompressPlugin(opts: IOpts): Promise<void>;
10
10
  export {};
11
- //# sourceMappingURL=compressPlugin.d.ts.map
@@ -1,102 +1,120 @@
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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
4
32
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addCompressPlugin = void 0;
7
- // @ts-ignore
8
- const css_minimizer_webpack_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/css-minimizer-webpack-plugin"));
9
- const terser_webpack_plugin_1 = __importDefault(require("../../compiled/terser-webpack-plugin"));
10
- const types_1 = require("../types");
11
- const getEsBuildTarget_1 = require("../utils/getEsBuildTarget");
33
+ 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));
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+
36
+ // src/config/compressPlugin.ts
37
+ var compressPlugin_exports = {};
38
+ __export(compressPlugin_exports, {
39
+ addCompressPlugin: () => addCompressPlugin
40
+ });
41
+ module.exports = __toCommonJS(compressPlugin_exports);
42
+ var import_css_minimizer_webpack_plugin = __toESM(require("@umijs/bundler-webpack/compiled/css-minimizer-webpack-plugin"));
43
+ var import_terser_webpack_plugin = __toESM(require("../../compiled/terser-webpack-plugin"));
44
+ var import_types = require("../types");
45
+ var import_getEsBuildTarget = require("../utils/getEsBuildTarget");
12
46
  async function addCompressPlugin(opts) {
13
- const { config, userConfig, env } = opts;
14
- const jsMinifier = userConfig.jsMinifier || types_1.JSMinifier.esbuild;
15
- const cssMinifier = userConfig.cssMinifier || types_1.CSSMinifier.esbuild;
16
- if (env === types_1.Env.development ||
17
- process.env.COMPRESS === 'none' ||
18
- (jsMinifier === types_1.JSMinifier.none && cssMinifier === types_1.CSSMinifier.none)) {
19
- config.optimization.minimize(false);
20
- return;
21
- }
22
- config.optimization.minimize(true);
23
- // esbuild transform only allow `string[]` as target
24
- const esbuildTarget = (0, getEsBuildTarget_1.getEsBuildTarget)({
25
- targets: userConfig.targets || {},
26
- });
27
- let minify;
28
- let terserOptions;
29
- if (jsMinifier === types_1.JSMinifier.esbuild) {
30
- minify = terser_webpack_plugin_1.default.esbuildMinify;
31
- terserOptions = {
32
- target: esbuildTarget,
33
- // remove all comments
34
- legalComments: 'none',
35
- };
36
- }
37
- else if (jsMinifier === types_1.JSMinifier.terser) {
38
- minify = terser_webpack_plugin_1.default.terserMinify;
39
- terserOptions = {
40
- format: {
41
- comments: false,
42
- },
43
- };
44
- }
45
- else if (jsMinifier === types_1.JSMinifier.swc) {
46
- minify = terser_webpack_plugin_1.default.swcMinify;
47
- }
48
- else if (jsMinifier === types_1.JSMinifier.uglifyJs) {
49
- minify = terser_webpack_plugin_1.default.uglifyJsMinify;
50
- terserOptions = {
51
- output: {
52
- comments: false,
53
- },
54
- };
55
- }
56
- else if (jsMinifier !== types_1.JSMinifier.none) {
57
- throw new Error(`Unsupported jsMinifier ${userConfig.jsMinifier}.`);
58
- }
47
+ const { config, userConfig, env } = opts;
48
+ const jsMinifier = userConfig.jsMinifier || import_types.JSMinifier.esbuild;
49
+ const cssMinifier = userConfig.cssMinifier || import_types.CSSMinifier.esbuild;
50
+ if (env === import_types.Env.development || process.env.COMPRESS === "none" || jsMinifier === import_types.JSMinifier.none && cssMinifier === import_types.CSSMinifier.none) {
51
+ config.optimization.minimize(false);
52
+ return;
53
+ }
54
+ config.optimization.minimize(true);
55
+ const esbuildTarget = (0, import_getEsBuildTarget.getEsBuildTarget)({
56
+ targets: userConfig.targets || {}
57
+ });
58
+ let minify;
59
+ let terserOptions;
60
+ if (jsMinifier === import_types.JSMinifier.esbuild) {
61
+ minify = import_terser_webpack_plugin.default.esbuildMinify;
59
62
  terserOptions = {
60
- ...terserOptions,
61
- ...userConfig.jsMinifierOptions,
63
+ target: esbuildTarget,
64
+ legalComments: "none"
62
65
  };
63
- if (jsMinifier !== types_1.JSMinifier.none) {
64
- config.optimization.minimizer(`js-${jsMinifier}`).use(terser_webpack_plugin_1.default, [
65
- {
66
- extractComments: false,
67
- minify,
68
- terserOptions,
69
- },
70
- ]);
71
- }
72
- let cssMinify;
73
- let minimizerOptions;
74
- if (cssMinifier === types_1.CSSMinifier.esbuild) {
75
- cssMinify = css_minimizer_webpack_plugin_1.default.esbuildMinify;
76
- minimizerOptions = {
77
- target: esbuildTarget,
78
- };
79
- }
80
- else if (cssMinifier === types_1.CSSMinifier.cssnano) {
81
- cssMinify = css_minimizer_webpack_plugin_1.default.cssnanoMinify;
82
- }
83
- else if (cssMinifier === types_1.CSSMinifier.parcelCSS) {
84
- cssMinify = css_minimizer_webpack_plugin_1.default.parcelCssMinify;
85
- }
86
- else if (cssMinifier !== types_1.CSSMinifier.none) {
87
- throw new Error(`Unsupported cssMinifier ${userConfig.cssMinifier}.`);
88
- }
89
- minimizerOptions = {
90
- ...minimizerOptions,
91
- ...userConfig.cssMinifierOptions,
66
+ } else if (jsMinifier === import_types.JSMinifier.terser) {
67
+ minify = import_terser_webpack_plugin.default.terserMinify;
68
+ terserOptions = {
69
+ format: {
70
+ comments: false
71
+ }
92
72
  };
93
- config.optimization
94
- .minimizer(`css-${cssMinifier}`)
95
- .use(css_minimizer_webpack_plugin_1.default, [
96
- {
97
- minify: cssMinify,
98
- minimizerOptions,
99
- },
73
+ } else if (jsMinifier === import_types.JSMinifier.swc) {
74
+ minify = import_terser_webpack_plugin.default.swcMinify;
75
+ } else if (jsMinifier === import_types.JSMinifier.uglifyJs) {
76
+ minify = import_terser_webpack_plugin.default.uglifyJsMinify;
77
+ terserOptions = {
78
+ output: {
79
+ comments: false
80
+ }
81
+ };
82
+ } else if (jsMinifier !== import_types.JSMinifier.none) {
83
+ throw new Error(`Unsupported jsMinifier ${userConfig.jsMinifier}.`);
84
+ }
85
+ terserOptions = __spreadValues(__spreadValues({}, terserOptions), userConfig.jsMinifierOptions);
86
+ if (jsMinifier !== import_types.JSMinifier.none) {
87
+ config.optimization.minimizer(`js-${jsMinifier}`).use(import_terser_webpack_plugin.default, [
88
+ {
89
+ extractComments: false,
90
+ minify,
91
+ terserOptions
92
+ }
100
93
  ]);
94
+ }
95
+ let cssMinify;
96
+ let minimizerOptions;
97
+ if (cssMinifier === import_types.CSSMinifier.esbuild) {
98
+ cssMinify = import_css_minimizer_webpack_plugin.default.esbuildMinify;
99
+ minimizerOptions = {
100
+ target: esbuildTarget
101
+ };
102
+ } else if (cssMinifier === import_types.CSSMinifier.cssnano) {
103
+ cssMinify = import_css_minimizer_webpack_plugin.default.cssnanoMinify;
104
+ } else if (cssMinifier === import_types.CSSMinifier.parcelCSS) {
105
+ cssMinify = import_css_minimizer_webpack_plugin.default.parcelCssMinify;
106
+ } else if (cssMinifier !== import_types.CSSMinifier.none) {
107
+ throw new Error(`Unsupported cssMinifier ${userConfig.cssMinifier}.`);
108
+ }
109
+ minimizerOptions = __spreadValues(__spreadValues({}, minimizerOptions), userConfig.cssMinifierOptions);
110
+ config.optimization.minimizer(`css-${cssMinifier}`).use(import_css_minimizer_webpack_plugin.default, [
111
+ {
112
+ minify: cssMinify,
113
+ minimizerOptions
114
+ }
115
+ ]);
101
116
  }
102
- exports.addCompressPlugin = addCompressPlugin;
117
+ // Annotate the CommonJS export names for ESM import in node:
118
+ 0 && (module.exports = {
119
+ addCompressPlugin
120
+ });
@@ -23,6 +23,6 @@ export interface IOpts {
23
23
  buildDependencies?: string[];
24
24
  cacheDirectory?: string;
25
25
  };
26
+ pkg?: Record<string, any>;
26
27
  }
27
28
  export declare function getConfig(opts: IOpts): Promise<Configuration>;
28
- //# sourceMappingURL=config.d.ts.map