@umijs/bundler-webpack 4.0.0-canary.20220718.1 → 4.0.0-canary.20220727.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 +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 -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 +170 -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 +120 -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
@@ -8,4 +8,3 @@ interface IOpts {
8
8
  }
9
9
  export declare function addCopyPlugin(opts: IOpts): Promise<void>;
10
10
  export {};
11
- //# sourceMappingURL=copyPlugin.d.ts.map
@@ -1,42 +1,61 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addCopyPlugin = void 0;
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
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
+ // copyPlugin.ts
20
+ var copyPlugin_exports = {};
21
+ __export(copyPlugin_exports, {
22
+ addCopyPlugin: () => addCopyPlugin
23
+ });
24
+ module.exports = __toCommonJS(copyPlugin_exports);
25
+ var import_fs = require("fs");
26
+ var import_path = require("path");
6
27
  async function addCopyPlugin(opts) {
7
- var _a;
8
- const { config, userConfig, cwd } = opts;
9
- const copyPatterns = [
10
- (0, fs_1.existsSync)((0, path_1.join)(cwd, 'public')) && {
11
- from: (0, path_1.join)(cwd, 'public'),
12
- // ref: https://github.com/webpack-contrib/copy-webpack-plugin#info
13
- // Set minimized so terser will not do minimize
14
- info: { minimized: true },
15
- },
16
- ...(userConfig.copy
17
- ? (_a = userConfig.copy) === null || _a === void 0 ? void 0 : _a.map((pattern) => {
18
- if (typeof pattern === 'string') {
19
- return {
20
- from: (0, path_1.resolve)(cwd, pattern),
21
- info: { minimized: true },
22
- };
23
- }
24
- return {
25
- from: (0, path_1.resolve)(cwd, pattern.from),
26
- to: (0, path_1.resolve)(cwd, pattern.to),
27
- info: { minimized: true },
28
- };
29
- })
30
- : []),
31
- ].filter(Boolean);
32
- if (copyPatterns.length) {
33
- config
34
- .plugin('copy')
35
- .use(require('@umijs/bundler-webpack/compiled/copy-webpack-plugin'), [
36
- {
37
- patterns: copyPatterns,
38
- },
39
- ]);
40
- }
28
+ var _a;
29
+ const { config, userConfig, cwd } = opts;
30
+ const publicDir = (0, import_path.join)(cwd, "public");
31
+ const copyPatterns = [
32
+ (0, import_fs.existsSync)(publicDir) && (0, import_fs.readdirSync)(publicDir).length && {
33
+ from: publicDir,
34
+ info: { minimized: true }
35
+ },
36
+ ...userConfig.copy ? (_a = userConfig.copy) == null ? void 0 : _a.map((pattern) => {
37
+ if (typeof pattern === "string") {
38
+ return {
39
+ from: (0, import_path.resolve)(cwd, pattern),
40
+ info: { minimized: true }
41
+ };
42
+ }
43
+ return {
44
+ from: (0, import_path.resolve)(cwd, pattern.from),
45
+ to: (0, import_path.resolve)(cwd, pattern.to),
46
+ info: { minimized: true }
47
+ };
48
+ }) : []
49
+ ].filter(Boolean);
50
+ if (copyPatterns.length) {
51
+ config.plugin("copy").use(require("@umijs/bundler-webpack/compiled/copy-webpack-plugin"), [
52
+ {
53
+ patterns: copyPatterns
54
+ }
55
+ ]);
56
+ }
41
57
  }
42
- exports.addCopyPlugin = addCopyPlugin;
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ addCopyPlugin
61
+ });
@@ -9,4 +9,3 @@ interface IOpts {
9
9
  }
10
10
  export declare function addCSSRules(opts: IOpts): Promise<void>;
11
11
  export {};
12
- //# sourceMappingURL=cssRules.d.ts.map
@@ -1,137 +1,142 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addCSSRules = void 0;
4
- const utils_1 = require("@umijs/utils");
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;
22
+ };
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
+ // cssRules.ts
40
+ var cssRules_exports = {};
41
+ __export(cssRules_exports, {
42
+ addCSSRules: () => addCSSRules
43
+ });
44
+ module.exports = __toCommonJS(cssRules_exports);
45
+ var import_utils = require("@umijs/utils");
5
46
  async function addCSSRules(opts) {
6
- const { config, userConfig } = opts;
7
- const rulesConfig = [
8
- { name: 'css', test: /\.css(\?.*)?$/ },
9
- {
10
- name: 'less',
11
- test: /\.less(\?.*)?$/,
12
- loader: require.resolve('@umijs/bundler-webpack/compiled/less-loader'),
13
- loaderOptions: {
14
- implementation: require.resolve('@umijs/bundler-utils/compiled/less'),
15
- lessOptions: {
16
- modifyVars: userConfig.theme,
17
- javascriptEnabled: true,
18
- ...userConfig.lessLoader,
19
- },
20
- },
21
- },
22
- {
23
- name: 'sass',
24
- test: /\.(sass|scss)(\?.*)?$/,
25
- loader: require.resolve('@umijs/bundler-webpack/compiled/sass-loader'),
26
- loaderOptions: userConfig.sassLoader || {},
47
+ const { config, userConfig } = opts;
48
+ const rulesConfig = [
49
+ { name: "css", test: /\.css(\?.*)?$/ },
50
+ {
51
+ name: "less",
52
+ test: /\.less(\?.*)?$/,
53
+ loader: require.resolve("@umijs/bundler-webpack/compiled/less-loader"),
54
+ loaderOptions: {
55
+ implementation: require.resolve("@umijs/bundler-utils/compiled/less"),
56
+ lessOptions: __spreadValues({
57
+ modifyVars: userConfig.theme,
58
+ javascriptEnabled: true
59
+ }, userConfig.lessLoader)
60
+ }
61
+ },
62
+ {
63
+ name: "sass",
64
+ test: /\.(sass|scss)(\?.*)?$/,
65
+ loader: require.resolve("@umijs/bundler-webpack/compiled/sass-loader"),
66
+ loaderOptions: userConfig.sassLoader || {}
67
+ }
68
+ ];
69
+ for (const { name, test, loader, loaderOptions } of rulesConfig) {
70
+ const rule = config.module.rule(name);
71
+ const nestRulesConfig = [
72
+ userConfig.autoCSSModules && {
73
+ rule: rule.test(test).oneOf("css-modules").resourceQuery(/modules/),
74
+ isCSSModules: true
75
+ },
76
+ {
77
+ rule: rule.test(test).oneOf("css").sideEffects(true),
78
+ isCSSModules: false
79
+ }
80
+ ].filter(Boolean);
81
+ for (const { rule: rule2, isCSSModules } of nestRulesConfig) {
82
+ if (userConfig.styleLoader) {
83
+ rule2.use("style-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/style-loader")).options(__spreadValues({ base: 0, esModule: true }, userConfig.styleLoader));
84
+ } else {
85
+ rule2.use("mini-css-extract-plugin").loader(require.resolve("@umijs/bundler-webpack/compiled/mini-css-extract-plugin/loader")).options({
86
+ publicPath: "./",
87
+ emit: true,
88
+ esModule: true
89
+ });
90
+ }
91
+ rule2.use("css-loader").loader(require.resolve("css-loader")).options(__spreadValues(__spreadValues({
92
+ importLoaders: 1,
93
+ esModule: true,
94
+ url: {
95
+ filter: (url) => {
96
+ if (url.startsWith("/"))
97
+ return false;
98
+ return true;
99
+ }
27
100
  },
28
- ];
29
- for (const { name, test, loader, loaderOptions } of rulesConfig) {
30
- const rule = config.module.rule(name);
31
- const nestRulesConfig = [
32
- userConfig.autoCSSModules && {
33
- rule: rule
34
- .test(test)
35
- .oneOf('css-modules')
36
- .resourceQuery(/modules/),
37
- isCSSModules: true,
38
- },
39
- {
40
- rule: rule.test(test).oneOf('css').sideEffects(true),
41
- isCSSModules: false,
42
- },
43
- ].filter(Boolean);
44
- // @ts-ignore
45
- for (const { rule, isCSSModules } of nestRulesConfig) {
46
- if (userConfig.styleLoader) {
47
- rule
48
- .use('style-loader')
49
- .loader(require.resolve('@umijs/bundler-webpack/compiled/style-loader'))
50
- .options({ base: 0, esModule: true, ...userConfig.styleLoader });
51
- }
52
- else {
53
- rule
54
- .use('mini-css-extract-plugin')
55
- .loader(require.resolve('@umijs/bundler-webpack/compiled/mini-css-extract-plugin/loader'))
56
- .options({
57
- publicPath: './',
58
- emit: true,
59
- esModule: true,
60
- });
61
- }
62
- rule
63
- .use('css-loader')
64
- .loader(require.resolve('css-loader'))
65
- .options({
66
- importLoaders: 1,
67
- esModule: true,
68
- url: {
69
- filter: (url) => {
70
- // Don't parse absolute URLs
71
- // ref: https://github.com/webpack-contrib/css-loader#url
72
- if (url.startsWith('/'))
73
- return false;
74
- return true;
75
- },
76
- },
77
- import: true,
78
- ...(isCSSModules
79
- ? {
80
- modules: {
81
- localIdentName: '[local]___[hash:base64:5]',
82
- ...userConfig.cssLoaderModules,
83
- // If SSR is enabled, we need to handling the css modules name hashing
84
- // and save the class names mapping into opts.cssModulesMapping
85
- // so the esbuild can use it to generate the correct name for the server side
86
- getLocalIdent: userConfig.ssr &&
87
- ((context, localIdentName, localName, opt) => {
88
- const classIdent = ((0, utils_1.winPath)(context.resourcePath).replace((0, utils_1.winPath)(ensureLastSlash(opt.context)), '') +
89
- '@' +
90
- localName).trim();
91
- let hash = Buffer.from(classIdent)
92
- .toString('base64')
93
- .replace(/=/g, '');
94
- hash = hash.substring(hash.length - 5);
95
- const result = localIdentName
96
- .replace(/\[local]/g, localName)
97
- .replace(/\[hash[^\[]*?]/g, hash);
98
- return result;
99
- }),
100
- },
101
- }
102
- : {}),
103
- ...userConfig.cssLoader,
104
- });
105
- rule
106
- .use('postcss-loader')
107
- .loader(require.resolve('@umijs/bundler-webpack/compiled/postcss-loader'))
108
- .options({
109
- postcssOptions: {
110
- ident: 'postcss',
111
- plugins: [
112
- require('@umijs/bundler-webpack/compiled/postcss-flexbugs-fixes'),
113
- require('postcss-preset-env')({
114
- browsers: opts.browsers,
115
- autoprefixer: {
116
- flexbox: 'no-2009',
117
- ...userConfig.autoprefixer,
118
- },
119
- stage: 3,
120
- }),
121
- ].concat(userConfig.extraPostCSSPlugins || []),
122
- ...userConfig.postcssLoader,
123
- },
124
- });
125
- if (loader) {
126
- rule
127
- .use(loader)
128
- .loader(typeof loader === 'string' ? require.resolve(loader) : loader)
129
- .options(loaderOptions || {});
130
- }
131
- }
101
+ import: true
102
+ }, isCSSModules ? {
103
+ modules: __spreadProps(__spreadValues({
104
+ localIdentName: "[local]___[hash:base64:5]"
105
+ }, userConfig.cssLoaderModules), {
106
+ getLocalIdent: userConfig.ssr && ((context, localIdentName, localName, opt) => {
107
+ const classIdent = ((0, import_utils.winPath)(context.resourcePath).replace((0, import_utils.winPath)(ensureLastSlash(opt.context)), "") + "@" + localName).trim();
108
+ let hash = Buffer.from(classIdent).toString("base64").replace(/=/g, "");
109
+ hash = hash.substring(hash.length - 5);
110
+ const result = localIdentName.replace(/\[local]/g, localName).replace(/\[hash[^\[]*?]/g, hash);
111
+ return result;
112
+ })
113
+ })
114
+ } : {}), userConfig.cssLoader));
115
+ rule2.use("postcss-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/postcss-loader")).options({
116
+ postcssOptions: __spreadValues({
117
+ ident: "postcss",
118
+ plugins: [
119
+ require("@umijs/bundler-webpack/compiled/postcss-flexbugs-fixes"),
120
+ require("postcss-preset-env")({
121
+ browsers: opts.browsers,
122
+ autoprefixer: __spreadValues({
123
+ flexbox: "no-2009"
124
+ }, userConfig.autoprefixer),
125
+ stage: 3
126
+ })
127
+ ].concat(userConfig.extraPostCSSPlugins || [])
128
+ }, userConfig.postcssLoader)
129
+ });
130
+ if (loader) {
131
+ rule2.use(loader).loader(typeof loader === "string" ? require.resolve(loader) : loader).options(loaderOptions || {});
132
+ }
132
133
  }
134
+ }
133
135
  }
134
- exports.addCSSRules = addCSSRules;
135
136
  function ensureLastSlash(path) {
136
- return path.endsWith('/') ? path : path + '/';
137
+ return path.endsWith("/") ? path : path + "/";
137
138
  }
139
+ // Annotate the CommonJS export names for ESM import in node:
140
+ 0 && (module.exports = {
141
+ addCSSRules
142
+ });
@@ -14,4 +14,3 @@ export declare function resolveDefine(opts: {
14
14
  };
15
15
  export declare function addDefinePlugin(opts: IOpts): Promise<void>;
16
16
  export {};
17
- //# sourceMappingURL=definePlugin.d.ts.map
@@ -1,41 +1,77 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addDefinePlugin = exports.resolveDefine = void 0;
4
- const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
5
- const prefixRE = /^UMI_APP_/;
6
- const ENV_SHOULD_PASS = ['NODE_ENV', 'HMR', 'SOCKET_SERVER', 'ERROR_OVERLAY'];
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, { get: all[name], enumerable: true });
22
+ };
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from))
26
+ if (!__hasOwnProp.call(to, key) && key !== except)
27
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
+ }
29
+ return to;
30
+ };
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // definePlugin.ts
34
+ var definePlugin_exports = {};
35
+ __export(definePlugin_exports, {
36
+ addDefinePlugin: () => addDefinePlugin,
37
+ resolveDefine: () => resolveDefine
38
+ });
39
+ module.exports = __toCommonJS(definePlugin_exports);
40
+ var import_webpack = require("@umijs/bundler-webpack/compiled/webpack");
41
+ var prefixRE = /^UMI_APP_/;
42
+ var ENV_SHOULD_PASS = ["NODE_ENV", "HMR", "SOCKET_SERVER", "ERROR_OVERLAY"];
7
43
  function resolveDefine(opts) {
8
- const env = {};
9
- Object.keys(process.env).forEach((key) => {
10
- if (prefixRE.test(key) || ENV_SHOULD_PASS.includes(key)) {
11
- env[key] = process.env[key];
12
- }
13
- });
14
- // Useful for resolving the correct path to static assets in `public`.
15
- // For example, <img src={process.env.PUBLIC_PATH + '/img/logo.png'} />.
16
- env.PUBLIC_PATH = opts.publicPath || '/';
17
- for (const key in env) {
18
- env[key] = JSON.stringify(env[key]);
44
+ const env = {};
45
+ Object.keys(process.env).forEach((key) => {
46
+ if (prefixRE.test(key) || ENV_SHOULD_PASS.includes(key)) {
47
+ env[key] = process.env[key];
19
48
  }
20
- const define = {};
21
- if (opts.define) {
22
- for (const key in opts.define) {
23
- define[key] = JSON.stringify(opts.define[key]);
24
- }
49
+ });
50
+ env.PUBLIC_PATH = opts.publicPath || "/";
51
+ for (const key in env) {
52
+ env[key] = JSON.stringify(env[key]);
53
+ }
54
+ const define = {};
55
+ if (opts.define) {
56
+ for (const key in opts.define) {
57
+ define[key] = JSON.stringify(opts.define[key]);
25
58
  }
26
- return {
27
- 'process.env': env,
28
- ...define,
29
- };
59
+ }
60
+ return __spreadValues({
61
+ "process.env": env
62
+ }, define);
30
63
  }
31
- exports.resolveDefine = resolveDefine;
32
64
  async function addDefinePlugin(opts) {
33
- const { config, userConfig } = opts;
34
- config.plugin('define').use(webpack_1.DefinePlugin, [
35
- resolveDefine({
36
- define: userConfig.define || {},
37
- publicPath: userConfig.publicPath,
38
- }),
39
- ]);
65
+ const { config, userConfig } = opts;
66
+ config.plugin("define").use(import_webpack.DefinePlugin, [
67
+ resolveDefine({
68
+ define: userConfig.define || {},
69
+ publicPath: userConfig.publicPath
70
+ })
71
+ ]);
40
72
  }
41
- exports.addDefinePlugin = addDefinePlugin;
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ addDefinePlugin,
76
+ resolveDefine
77
+ });
@@ -10,4 +10,3 @@ export interface Options extends DeadCodeParams {
10
10
  export declare const disabledFolders: string[];
11
11
  declare const detectDeadCode: (compilation: Compilation, options: Options) => void;
12
12
  export default detectDeadCode;
13
- //# sourceMappingURL=detectDeadCode.d.ts.map