@umijs/bundler-webpack 4.0.0-canary.20220718.2 → 4.0.0-canary.20220720.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 (151) 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 +58 -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 +146 -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 +119 -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 +0 -1
  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 +7 -10
  102. package/dist/build.d.ts.map +0 -1
  103. package/dist/cli.d.ts.map +0 -1
  104. package/dist/client/client.d.ts +0 -2
  105. package/dist/client/client.d.ts.map +0 -1
  106. package/dist/client/client.js +0 -245
  107. package/dist/config/_sampleFeature.d.ts.map +0 -1
  108. package/dist/config/assetRules.d.ts.map +0 -1
  109. package/dist/config/bundleAnalyzerPlugin.d.ts.map +0 -1
  110. package/dist/config/compressPlugin.d.ts.map +0 -1
  111. package/dist/config/config.d.ts.map +0 -1
  112. package/dist/config/copyPlugin.d.ts.map +0 -1
  113. package/dist/config/cssRules.d.ts.map +0 -1
  114. package/dist/config/definePlugin.d.ts.map +0 -1
  115. package/dist/config/detectDeadCode.d.ts.map +0 -1
  116. package/dist/config/detectDeadCodePlugin.d.ts.map +0 -1
  117. package/dist/config/fastRefreshPlugin.d.ts.map +0 -1
  118. package/dist/config/forkTSCheckerPlugin.d.ts.map +0 -1
  119. package/dist/config/harmonyLinkingErrorPlugin.d.ts.map +0 -1
  120. package/dist/config/ignorePlugin.d.ts.map +0 -1
  121. package/dist/config/javaScriptRules.d.ts.map +0 -1
  122. package/dist/config/manifestPlugin.d.ts.map +0 -1
  123. package/dist/config/miniCSSExtractPlugin.d.ts.map +0 -1
  124. package/dist/config/nodePolyfill.d.ts.map +0 -1
  125. package/dist/config/nodePrefixPlugin.d.ts.map +0 -1
  126. package/dist/config/progressPlugin.d.ts.map +0 -1
  127. package/dist/config/purgecssWebpackPlugin.d.ts.map +0 -1
  128. package/dist/config/speedMeasureWebpackPlugin.d.ts.map +0 -1
  129. package/dist/config/ssrPlugin.d.ts.map +0 -1
  130. package/dist/config/svgRules.d.ts.map +0 -1
  131. package/dist/constants.d.ts.map +0 -1
  132. package/dist/dev.d.ts.map +0 -1
  133. package/dist/index.d.ts.map +0 -1
  134. package/dist/loader/svgr.d.ts.map +0 -1
  135. package/dist/loader/swc.d.ts.map +0 -1
  136. package/dist/parcelCSS.d.ts.map +0 -1
  137. package/dist/plugins/ProgressPlugin.d.ts.map +0 -1
  138. package/dist/plugins/RuntimePublicPathPlugin.d.ts.map +0 -1
  139. package/dist/plugins/_SamplePlugin.d.ts.map +0 -1
  140. package/dist/requireHook.d.ts.map +0 -1
  141. package/dist/schema.d.ts.map +0 -1
  142. package/dist/server/server.d.ts.map +0 -1
  143. package/dist/server/ws.d.ts.map +0 -1
  144. package/dist/swcPlugins/autoCSSModules.d.ts.map +0 -1
  145. package/dist/swcPlugins/changeImportFromString.d.ts.map +0 -1
  146. package/dist/swcPlugins/lockCoreJS.d.ts.map +0 -1
  147. package/dist/types.d.ts.map +0 -1
  148. package/dist/utils/browsersList.d.ts.map +0 -1
  149. package/dist/utils/depMatch.d.ts.map +0 -1
  150. package/dist/utils/formatWebpackMessages.d.ts.map +0 -1
  151. package/dist/utils/getEsBuildTarget.d.ts.map +0 -1
@@ -1,16 +1,40 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addIgnorePlugin = void 0;
4
- const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
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
+ // ignorePlugin.ts
20
+ var ignorePlugin_exports = {};
21
+ __export(ignorePlugin_exports, {
22
+ addIgnorePlugin: () => addIgnorePlugin
23
+ });
24
+ module.exports = __toCommonJS(ignorePlugin_exports);
25
+ var import_webpack = require("@umijs/bundler-webpack/compiled/webpack");
5
26
  async function addIgnorePlugin(opts) {
6
- const { config, userConfig } = opts;
7
- if (userConfig.ignoreMomentLocale) {
8
- config.plugin('ignore-moment-locale').use(webpack_1.IgnorePlugin, [
9
- {
10
- resourceRegExp: /^\.\/locale$/,
11
- contextRegExp: /moment$/,
12
- },
13
- ]);
14
- }
27
+ const { config, userConfig } = opts;
28
+ if (userConfig.ignoreMomentLocale) {
29
+ config.plugin("ignore-moment-locale").use(import_webpack.IgnorePlugin, [
30
+ {
31
+ resourceRegExp: /^\.\/locale$/,
32
+ contextRegExp: /moment$/
33
+ }
34
+ ]);
35
+ }
15
36
  }
16
- exports.addIgnorePlugin = addIgnorePlugin;
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ addIgnorePlugin
40
+ });
@@ -14,4 +14,3 @@ interface IOpts {
14
14
  }
15
15
  export declare function addJavaScriptRules(opts: IOpts): Promise<void>;
16
16
  export {};
17
- //# sourceMappingURL=javaScriptRules.d.ts.map
@@ -1,182 +1,153 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addJavaScriptRules = void 0;
4
- const mfsu_1 = require("@umijs/mfsu");
5
- const utils_1 = require("@umijs/utils");
6
- const path_1 = require("path");
7
- const webpack_1 = require("../../compiled/webpack");
8
- const constants_1 = require("../constants");
9
- const types_1 = require("../types");
10
- const depMatch_1 = require("../utils/depMatch");
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 __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ 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));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // javaScriptRules.ts
23
+ var javaScriptRules_exports = {};
24
+ __export(javaScriptRules_exports, {
25
+ addJavaScriptRules: () => addJavaScriptRules
26
+ });
27
+ module.exports = __toCommonJS(javaScriptRules_exports);
28
+ var import_mfsu = require("@umijs/mfsu");
29
+ var import_utils = require("@umijs/utils");
30
+ var import_path = require("path");
31
+ var import_webpack = require("../../compiled/webpack");
32
+ var import_constants = require("../constants");
33
+ var import_types = require("../types");
34
+ var import_depMatch = require("../utils/depMatch");
11
35
  async function addJavaScriptRules(opts) {
12
- var _a, _b;
13
- const { config, userConfig, cwd, name } = opts;
14
- const isDev = opts.env === types_1.Env.development;
15
- const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== constants_1.MFSU_NAME;
16
- const depPkgs = Object.assign({}, (0, depMatch_1.es5ImcompatibleVersionsToPkg)());
17
- const srcRules = [
18
- config.module
19
- .rule('src')
20
- .test(/\.(js|mjs)$/)
21
- .include.add([
22
- cwd,
23
- // import module out of cwd using APP_ROOT
24
- // issue: https://github.com/umijs/umi/issues/5594
25
- ...(process.env.APP_ROOT ? [process.cwd()] : []),
26
- ])
27
- .end()
28
- .exclude.add(/node_modules/)
29
- .end(),
30
- config.module.rule('jsx-ts-tsx').test(/\.(jsx|ts|tsx)$/),
31
- config.module
32
- .rule('extra-src')
33
- .test(/\.(js|mjs)$/)
34
- .include.add([
35
- // support extraBabelIncludes
36
- ...opts.extraBabelIncludes.map((p) => {
37
- // handle absolute path
38
- if ((0, path_1.isAbsolute)(p)) {
39
- return p;
40
- }
41
- // resolve npm package name
42
- try {
43
- if (p.startsWith('./')) {
44
- return require.resolve(p, { paths: [cwd] });
45
- }
46
- // use resolve instead of require.resolve
47
- // since require.resolve may meet the ERR_PACKAGE_PATH_NOT_EXPORTED error
48
- return (0, path_1.dirname)(utils_1.resolve.sync(`${p}/package.json`, { basedir: cwd }));
49
- }
50
- catch (e) {
51
- if (e.code === 'MODULE_NOT_FOUND') {
52
- throw new Error('Cannot resolve extraBabelIncludes: ' + p);
53
- }
54
- throw e;
55
- }
56
- }),
57
- // support es5ImcompatibleVersions
58
- (path) => {
59
- try {
60
- // do src transform for bundler-webpack/client/client/client.js
61
- if (path.includes('client/client/client'))
62
- return true;
63
- return (0, depMatch_1.isMatch)({ path, pkgs: depPkgs });
64
- }
65
- catch (e) {
66
- console.error(utils_1.chalk.red(e));
67
- throw e;
68
- }
69
- },
70
- ])
71
- .end(),
72
- ];
73
- if (userConfig.mdx) {
74
- srcRules.push(config.module.rule('markdown').test(/\.mdx?$/));
75
- }
76
- const depRules = [
77
- config.module
78
- .rule('dep')
79
- .test(/\.(js|mjs)$/)
80
- .include.add(/node_modules/)
81
- .end()
82
- .exclude.add((path) => {
83
- try {
84
- return (0, depMatch_1.isMatch)({ path, pkgs: depPkgs });
85
- }
86
- catch (e) {
87
- console.error(utils_1.chalk.red(e));
88
- throw e;
89
- }
90
- })
91
- .end(),
92
- ];
93
- srcRules
94
- .concat(depRules)
95
- .forEach((rule) => rule.resolve.set('fullySpecified', false));
96
- // const prefix = existsSync(join(cwd, 'src')) ? join(cwd, 'src') : cwd;
97
- const srcTranspiler = userConfig.srcTranspiler || types_1.Transpiler.babel;
98
- srcRules.forEach((rule) => {
99
- if (srcTranspiler === types_1.Transpiler.babel) {
100
- rule
101
- .use('babel-loader')
102
- .loader(require.resolve('../../compiled/babel-loader'))
103
- .options({
104
- // Tell babel to guess the type, instead assuming all files are modules
105
- // https://github.com/webpack/webpack/issues/4039#issuecomment-419284940
106
- sourceType: 'unambiguous',
107
- babelrc: false,
108
- cacheDirectory: false,
109
- // process.env.BABEL_CACHE !== 'none'
110
- // ? join(cwd, `.umi/.cache/babel-loader`)
111
- // : false,
112
- targets: userConfig.targets,
113
- presets: [
114
- opts.babelPreset || [
115
- require.resolve('@umijs/babel-preset-umi'),
116
- {
117
- presetEnv: {},
118
- presetReact: {},
119
- presetTypeScript: {},
120
- pluginTransformRuntime: {},
121
- pluginLockCoreJS: {},
122
- pluginDynamicImportNode: false,
123
- pluginAutoCSSModules: userConfig.autoCSSModules,
124
- },
125
- ],
126
- ...opts.extraBabelPresets,
127
- ...(userConfig.extraBabelPresets || []).filter(Boolean),
128
- ],
129
- plugins: [
130
- useFastRefresh && require.resolve('react-refresh/babel'),
131
- ...opts.extraBabelPlugins,
132
- ...(userConfig.extraBabelPlugins || []),
133
- ].filter(Boolean),
134
- });
36
+ var _a, _b;
37
+ const { config, userConfig, cwd, name } = opts;
38
+ const isDev = opts.env === import_types.Env.development;
39
+ const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== import_constants.MFSU_NAME;
40
+ const depPkgs = Object.assign({}, (0, import_depMatch.es5ImcompatibleVersionsToPkg)());
41
+ const srcRules = [
42
+ config.module.rule("src").test(/\.(js|mjs)$/).include.add([
43
+ cwd,
44
+ ...process.env.APP_ROOT ? [process.cwd()] : []
45
+ ]).end().exclude.add(/node_modules/).end(),
46
+ config.module.rule("jsx-ts-tsx").test(/\.(jsx|ts|tsx)$/),
47
+ config.module.rule("extra-src").test(/\.(js|mjs)$/).include.add([
48
+ ...opts.extraBabelIncludes.map((p) => {
49
+ if ((0, import_path.isAbsolute)(p)) {
50
+ return p;
135
51
  }
136
- else if (srcTranspiler === types_1.Transpiler.swc) {
137
- const AutoCSSModule = require('../swcPlugins/autoCSSModules').default;
138
- rule
139
- .use('swc-loader')
140
- .loader(require.resolve('../loader/swc'))
141
- .options({
142
- plugin: (m) => new AutoCSSModule().visitProgram(m),
143
- });
52
+ try {
53
+ if (p.startsWith("./")) {
54
+ return require.resolve(p, { paths: [cwd] });
55
+ }
56
+ return (0, import_path.dirname)(import_utils.resolve.sync(`${p}/package.json`, { basedir: cwd }));
57
+ } catch (e) {
58
+ if (e.code === "MODULE_NOT_FOUND") {
59
+ throw new Error("Cannot resolve extraBabelIncludes: " + p);
60
+ }
61
+ throw e;
144
62
  }
145
- else if (srcTranspiler === types_1.Transpiler.esbuild) {
146
- rule
147
- .use('esbuild-loader')
148
- .loader(mfsu_1.esbuildLoader)
149
- .options({
150
- target: isDev ? 'esnext' : 'es2015',
151
- handler: [mfsu_1.autoCssModulesHandler, ...opts.extraEsbuildLoaderHandler],
152
- });
153
- // esbuild loader can not auto import `React`
154
- config.plugin('react-provide-plugin').use(webpack_1.ProvidePlugin, [
155
- {
156
- React: 'react',
157
- },
158
- ]);
63
+ }),
64
+ (path) => {
65
+ try {
66
+ if (path.includes("client/client/client"))
67
+ return true;
68
+ return (0, import_depMatch.isMatch)({ path, pkgs: depPkgs });
69
+ } catch (e) {
70
+ console.error(import_utils.chalk.red(e));
71
+ throw e;
159
72
  }
160
- else {
161
- throw new Error(`Unsupported srcTranspiler ${srcTranspiler}.`);
73
+ }
74
+ ]).end()
75
+ ];
76
+ if (userConfig.mdx) {
77
+ srcRules.push(config.module.rule("markdown").test(/\.mdx?$/));
78
+ }
79
+ const depRules = [
80
+ config.module.rule("dep").test(/\.(js|mjs)$/).include.add(/node_modules/).end().exclude.add((path) => {
81
+ try {
82
+ return (0, import_depMatch.isMatch)({ path, pkgs: depPkgs });
83
+ } catch (e) {
84
+ console.error(import_utils.chalk.red(e));
85
+ throw e;
86
+ }
87
+ }).end()
88
+ ];
89
+ srcRules.concat(depRules).forEach((rule) => rule.resolve.set("fullySpecified", false));
90
+ const srcTranspiler = userConfig.srcTranspiler || import_types.Transpiler.babel;
91
+ srcRules.forEach((rule) => {
92
+ if (srcTranspiler === import_types.Transpiler.babel) {
93
+ rule.use("babel-loader").loader(require.resolve("../../compiled/babel-loader")).options({
94
+ sourceType: "unambiguous",
95
+ babelrc: false,
96
+ cacheDirectory: false,
97
+ targets: userConfig.targets,
98
+ presets: [
99
+ opts.babelPreset || [
100
+ require.resolve("@umijs/babel-preset-umi"),
101
+ {
102
+ presetEnv: {},
103
+ presetReact: {},
104
+ presetTypeScript: {},
105
+ pluginTransformRuntime: {},
106
+ pluginLockCoreJS: {},
107
+ pluginDynamicImportNode: false,
108
+ pluginAutoCSSModules: userConfig.autoCSSModules
109
+ }
110
+ ],
111
+ ...opts.extraBabelPresets,
112
+ ...(userConfig.extraBabelPresets || []).filter(Boolean)
113
+ ],
114
+ plugins: [
115
+ useFastRefresh && require.resolve("react-refresh/babel"),
116
+ ...opts.extraBabelPlugins,
117
+ ...userConfig.extraBabelPlugins || []
118
+ ].filter(Boolean)
119
+ });
120
+ } else if (srcTranspiler === import_types.Transpiler.swc) {
121
+ const AutoCSSModule = require("../swcPlugins/autoCSSModules").default;
122
+ rule.use("swc-loader").loader(require.resolve("../loader/swc")).options({
123
+ plugin: (m) => new AutoCSSModule().visitProgram(m)
124
+ });
125
+ } else if (srcTranspiler === import_types.Transpiler.esbuild) {
126
+ rule.use("esbuild-loader").loader(import_mfsu.esbuildLoader).options({
127
+ target: isDev ? "esnext" : "es2015",
128
+ handler: [import_mfsu.autoCssModulesHandler, ...opts.extraEsbuildLoaderHandler]
129
+ });
130
+ config.plugin("react-provide-plugin").use(import_webpack.ProvidePlugin, [
131
+ {
132
+ React: "react"
162
133
  }
163
- });
164
- if (userConfig.mdx) {
165
- config.module
166
- .rule('mdx')
167
- .test(/\.mdx?$/)
168
- .use('mdx-loader')
169
- .loader((_a = userConfig.mdx) === null || _a === void 0 ? void 0 : _a.loader)
170
- .options((_b = userConfig.mdx) === null || _b === void 0 ? void 0 : _b.loaderOptions);
134
+ ]);
135
+ } else {
136
+ throw new Error(`Unsupported srcTranspiler ${srcTranspiler}.`);
171
137
  }
172
- const depTranspiler = userConfig.depTranspiler || types_1.Transpiler.none;
173
- depRules.forEach((_rule) => {
174
- if (depTranspiler === types_1.Transpiler.none) {
175
- // noop
176
- }
177
- else {
178
- throw new Error(`Unsupported depTranspiler ${depTranspiler}.`);
179
- }
180
- });
138
+ });
139
+ if (userConfig.mdx) {
140
+ config.module.rule("mdx").test(/\.mdx?$/).use("mdx-loader").loader((_a = userConfig.mdx) == null ? void 0 : _a.loader).options((_b = userConfig.mdx) == null ? void 0 : _b.loaderOptions);
141
+ }
142
+ const depTranspiler = userConfig.depTranspiler || import_types.Transpiler.none;
143
+ depRules.forEach((_rule) => {
144
+ if (depTranspiler === import_types.Transpiler.none) {
145
+ } else {
146
+ throw new Error(`Unsupported depTranspiler ${depTranspiler}.`);
147
+ }
148
+ });
181
149
  }
182
- exports.addJavaScriptRules = addJavaScriptRules;
150
+ // Annotate the CommonJS export names for ESM import in node:
151
+ 0 && (module.exports = {
152
+ addJavaScriptRules
153
+ });
@@ -9,4 +9,3 @@ interface IOpts {
9
9
  }
10
10
  export declare function addManifestPlugin(opts: IOpts): Promise<void>;
11
11
  export {};
12
- //# sourceMappingURL=manifestPlugin.d.ts.map
@@ -1,17 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addManifestPlugin = void 0;
4
- // @ts-ignore
5
- const webpack_manifest_plugin_1 = require("@umijs/bundler-webpack/compiled/webpack-manifest-plugin");
6
- async function addManifestPlugin(opts) {
7
- const { config, userConfig } = opts;
8
- if (userConfig.manifest) {
9
- config.plugin('manifest-plugin').use(webpack_manifest_plugin_1.WebpackManifestPlugin, [
10
- {
11
- fileName: 'asset-manifest.json',
12
- ...userConfig.manifest,
13
- },
14
- ]);
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]);
15
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
+ // manifestPlugin.ts
34
+ var manifestPlugin_exports = {};
35
+ __export(manifestPlugin_exports, {
36
+ addManifestPlugin: () => addManifestPlugin
37
+ });
38
+ module.exports = __toCommonJS(manifestPlugin_exports);
39
+ var import_webpack_manifest_plugin = require("@umijs/bundler-webpack/compiled/webpack-manifest-plugin");
40
+ async function addManifestPlugin(opts) {
41
+ const { config, userConfig } = opts;
42
+ if (userConfig.manifest) {
43
+ config.plugin("manifest-plugin").use(import_webpack_manifest_plugin.WebpackManifestPlugin, [
44
+ __spreadValues({
45
+ fileName: "asset-manifest.json"
46
+ }, userConfig.manifest)
47
+ ]);
48
+ }
16
49
  }
17
- exports.addManifestPlugin = addManifestPlugin;
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ addManifestPlugin
53
+ });
@@ -9,4 +9,3 @@ interface IOpts {
9
9
  }
10
10
  export declare function addMiniCSSExtractPlugin(opts: IOpts): Promise<void>;
11
11
  export {};
12
- //# sourceMappingURL=miniCSSExtractPlugin.d.ts.map
@@ -1,25 +1,45 @@
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 __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
4
10
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addMiniCSSExtractPlugin = void 0;
7
- // @ts-ignore
8
- const mini_css_extract_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/mini-css-extract-plugin"));
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ 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));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // miniCSSExtractPlugin.ts
23
+ var miniCSSExtractPlugin_exports = {};
24
+ __export(miniCSSExtractPlugin_exports, {
25
+ addMiniCSSExtractPlugin: () => addMiniCSSExtractPlugin
26
+ });
27
+ module.exports = __toCommonJS(miniCSSExtractPlugin_exports);
28
+ var import_mini_css_extract_plugin = __toESM(require("@umijs/bundler-webpack/compiled/mini-css-extract-plugin"));
9
29
  async function addMiniCSSExtractPlugin(opts) {
10
- const { config, userConfig, useHash } = opts;
11
- const hash = useHash ? '.[contenthash:8]' : '';
12
- if (!userConfig.styleLoader) {
13
- config.plugin('mini-css-extract-plugin').use(mini_css_extract_plugin_1.default, [
14
- {
15
- filename: `[name]${hash}.css`,
16
- chunkFilename: opts.userConfig.ssr
17
- ? // TODO: FIXME
18
- `umi${hash}.css`
19
- : `[name]${hash}.chunk.css`,
20
- ignoreOrder: true,
21
- },
22
- ]);
23
- }
30
+ const { config, userConfig, useHash } = opts;
31
+ const hash = useHash ? ".[contenthash:8]" : "";
32
+ if (!userConfig.styleLoader) {
33
+ config.plugin("mini-css-extract-plugin").use(import_mini_css_extract_plugin.default, [
34
+ {
35
+ filename: `[name]${hash}.css`,
36
+ chunkFilename: opts.userConfig.ssr ? `umi${hash}.css` : `[name]${hash}.chunk.css`,
37
+ ignoreOrder: true
38
+ }
39
+ ]);
40
+ }
24
41
  }
25
- exports.addMiniCSSExtractPlugin = addMiniCSSExtractPlugin;
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ addMiniCSSExtractPlugin
45
+ });
@@ -8,4 +8,3 @@ interface IOpts {
8
8
  }
9
9
  export declare function addNodePolyfill(opts: IOpts): Promise<void>;
10
10
  export {};
11
- //# sourceMappingURL=nodePolyfill.d.ts.map
@@ -1,28 +1,67 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addNodePolyfill = void 0;
4
- const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
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 __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+
36
+ // nodePolyfill.ts
37
+ var nodePolyfill_exports = {};
38
+ __export(nodePolyfill_exports, {
39
+ addNodePolyfill: () => addNodePolyfill
40
+ });
41
+ module.exports = __toCommonJS(nodePolyfill_exports);
42
+ var import_webpack = require("@umijs/bundler-webpack/compiled/webpack");
5
43
  async function addNodePolyfill(opts) {
6
- const { config } = opts;
7
- const nodeLibs = require('node-libs-browser');
8
- config.plugin('node-polyfill-provider').use(webpack_1.ProvidePlugin, [
9
- {
10
- Buffer: ['buffer', 'Buffer'],
11
- process: nodeLibs['process'],
12
- },
13
- ]);
14
- config.resolve.fallback.merge({
15
- ...Object.keys(nodeLibs).reduce((memo, key) => {
16
- if (nodeLibs[key]) {
17
- memo[key] = nodeLibs[key];
18
- }
19
- else {
20
- memo[key] = false;
21
- }
22
- return memo;
23
- }, {}),
24
- http: false,
25
- https: false,
26
- });
44
+ const { config } = opts;
45
+ const nodeLibs = require("node-libs-browser");
46
+ config.plugin("node-polyfill-provider").use(import_webpack.ProvidePlugin, [
47
+ {
48
+ Buffer: ["buffer", "Buffer"],
49
+ process: nodeLibs["process"]
50
+ }
51
+ ]);
52
+ config.resolve.fallback.merge(__spreadProps(__spreadValues({}, Object.keys(nodeLibs).reduce((memo, key) => {
53
+ if (nodeLibs[key]) {
54
+ memo[key] = nodeLibs[key];
55
+ } else {
56
+ memo[key] = false;
57
+ }
58
+ return memo;
59
+ }, {})), {
60
+ http: false,
61
+ https: false
62
+ }));
27
63
  }
28
- exports.addNodePolyfill = addNodePolyfill;
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ addNodePolyfill
67
+ });
@@ -9,4 +9,3 @@ interface IOpts {
9
9
  }
10
10
  export declare function addNodePrefixPlugin(opts: IOpts): Promise<void>;
11
11
  export {};
12
- //# sourceMappingURL=nodePrefixPlugin.d.ts.map