@umijs/bundler-webpack 4.0.0-rc.2 → 4.0.0-rc.22

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 (113) hide show
  1. package/client/client/client.js +65 -37
  2. package/client/constants.js +9 -0
  3. package/compiled/autoprefixer/browserslist/index.d.ts +2 -0
  4. package/compiled/autoprefixer/index.js +3 -3
  5. package/compiled/autoprefixer/postcss/lib/declaration.d.ts +1 -1
  6. package/compiled/autoprefixer/postcss/lib/node.d.ts +2 -2
  7. package/compiled/babel-loader/index.js +2 -2
  8. package/compiled/copy-webpack-plugin/{576.index.js → 939.index.js} +11 -11
  9. package/compiled/copy-webpack-plugin/index.js +12 -12
  10. package/compiled/css-minimizer-webpack-plugin/index.js +7 -7
  11. package/compiled/cssnano/index.js +6 -6
  12. package/compiled/cssnano/package.json +1 -1
  13. package/compiled/express.d.ts +2 -0
  14. package/compiled/fork-ts-checker-webpack-plugin/index.js +7 -13
  15. package/compiled/http-proxy-middleware/index.js +10 -10
  16. package/compiled/mini-css-extract-plugin/index.js +440 -401
  17. package/compiled/mini-css-extract-plugin/loader.js +3 -1
  18. package/compiled/mini-css-extract-plugin/utils.js +2 -0
  19. package/compiled/{tapable → react-refresh}/LICENSE +6 -6
  20. package/compiled/react-refresh/index.js +9 -7
  21. package/compiled/react-refresh/package.json +1 -0
  22. package/compiled/terser/index.js +1 -1
  23. package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
  24. package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
  25. package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
  26. package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
  27. package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
  28. package/compiled/webpack/RuleSetCompiler.js +1 -0
  29. package/compiled/webpack/UseEffectRulePlugin.js +1 -0
  30. package/compiled/webpack/deepImports.json +6 -1
  31. package/compiled/webpack/index.js +5155 -3422
  32. package/compiled/webpack/types.d.ts +606 -171
  33. package/compiled/webpack-dev-middleware/index.js +8 -7
  34. package/compiled/webpack-manifest-plugin/index.js +1 -1
  35. package/dist/build.d.ts +1 -0
  36. package/dist/build.js +48 -57
  37. package/dist/cli.js +6 -15
  38. package/dist/client/client.js +57 -51
  39. package/dist/config/_sampleFeature.js +6 -17
  40. package/dist/config/assetRules.js +44 -55
  41. package/dist/config/bundleAnalyzerPlugin.js +12 -23
  42. package/dist/config/compressPlugin.js +89 -64
  43. package/dist/config/config.d.ts +2 -0
  44. package/dist/config/config.js +178 -179
  45. package/dist/config/copyPlugin.js +29 -40
  46. package/dist/config/cssRules.js +93 -83
  47. package/dist/config/definePlugin.js +11 -19
  48. package/dist/config/detectDeadCode.js +1 -1
  49. package/dist/config/detectDeadCodePlugin.js +21 -22
  50. package/dist/config/fastRefreshPlugin.js +11 -22
  51. package/dist/config/forkTSCheckerPlugin.js +11 -22
  52. package/dist/config/harmonyLinkingErrorPlugin.js +3 -14
  53. package/dist/config/ignorePlugin.js +10 -21
  54. package/dist/config/javaScriptRules.d.ts +1 -0
  55. package/dist/config/javaScriptRules.js +152 -138
  56. package/dist/config/manifestPlugin.js +10 -18
  57. package/dist/config/miniCSSExtractPlugin.js +12 -23
  58. package/dist/config/nodePolyfill.js +14 -20
  59. package/dist/config/nodePrefixPlugin.d.ts +11 -0
  60. package/dist/config/nodePrefixPlugin.js +14 -0
  61. package/dist/config/progressPlugin.js +7 -18
  62. package/dist/config/purgecssWebpackPlugin.js +15 -26
  63. package/dist/config/speedMeasureWebpackPlugin.js +12 -23
  64. package/dist/config/svgRules.js +44 -47
  65. package/dist/constants.d.ts +1 -0
  66. package/dist/constants.js +7 -1
  67. package/dist/dev.d.ts +4 -0
  68. package/dist/dev.js +115 -94
  69. package/dist/index.d.ts +4 -1
  70. package/dist/index.js +5 -1
  71. package/dist/loader/svgr.js +4 -13
  72. package/dist/loader/swc.js +9 -14
  73. package/dist/plugins/ProgressPlugin.js +2 -2
  74. package/dist/plugins/RuntimePublicPathPlugin.js +4 -1
  75. package/dist/schema.js +29 -13
  76. package/dist/server/server.d.ts +3 -1
  77. package/dist/server/server.js +166 -148
  78. package/dist/server/ws.d.ts +7 -2
  79. package/dist/swcPlugins/autoCSSModules.js +3 -1
  80. package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
  81. package/dist/swcPlugins/changeImportFromString.js +10 -0
  82. package/dist/swcPlugins/lockCoreJS.d.ts +1 -1
  83. package/dist/swcPlugins/lockCoreJS.js +3 -2
  84. package/dist/types.d.ts +4 -0
  85. package/dist/types.js +1 -0
  86. package/dist/utils/getEsBuildTarget.d.ts +5 -0
  87. package/dist/utils/getEsBuildTarget.js +12 -0
  88. package/package.json +33 -35
  89. package/compiled/css-loader/LICENSE +0 -20
  90. package/compiled/css-loader/api.js +0 -102
  91. package/compiled/css-loader/getUrl.js +0 -29
  92. package/compiled/css-loader/index.js +0 -2
  93. package/compiled/css-loader/noSourceMaps.js +0 -5
  94. package/compiled/css-loader/package.json +0 -1
  95. package/compiled/css-loader/sourceMaps.js +0 -22
  96. package/compiled/express/LICENSE +0 -24
  97. package/compiled/express/body-parser/index.d.ts +0 -104
  98. package/compiled/express/connect/index.d.ts +0 -93
  99. package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
  100. package/compiled/express/index.d.ts +0 -133
  101. package/compiled/express/index.js +0 -321
  102. package/compiled/express/mime/index.d.ts +0 -35
  103. package/compiled/express/package.json +0 -1
  104. package/compiled/express/qs/index.d.ts +0 -62
  105. package/compiled/express/range-parser/index.d.ts +0 -35
  106. package/compiled/express/serve-static/index.d.ts +0 -108
  107. package/compiled/less/index.js +0 -31
  108. package/compiled/less/package.json +0 -1
  109. package/compiled/tapable/index.js +0 -1
  110. package/compiled/tapable/package.json +0 -1
  111. package/compiled/tapable/tapable.d.ts +0 -116
  112. package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
  113. package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -65
@@ -1,98 +1,108 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addCSSRules = void 0;
13
- function addCSSRules(opts) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- const { config, userConfig } = opts;
16
- const rulesConfig = [
17
- { name: 'css', test: /\.css(\?.*)?$/ },
18
- {
19
- name: 'less',
20
- test: /\.less(\?.*)?$/,
21
- loader: require.resolve('@umijs/bundler-webpack/compiled/less-loader'),
22
- loaderOptions: {
23
- implementation: require.resolve('@umijs/bundler-webpack/compiled/less'),
24
- lessOptions: Object.assign({ modifyVars: userConfig.theme, javascriptEnabled: true }, userConfig.lessLoader),
4
+ async function addCSSRules(opts) {
5
+ const { config, userConfig } = opts;
6
+ const rulesConfig = [
7
+ { name: 'css', test: /\.css(\?.*)?$/ },
8
+ {
9
+ name: 'less',
10
+ test: /\.less(\?.*)?$/,
11
+ loader: require.resolve('@umijs/bundler-webpack/compiled/less-loader'),
12
+ loaderOptions: {
13
+ implementation: require.resolve('@umijs/bundler-utils/compiled/less'),
14
+ lessOptions: {
15
+ modifyVars: userConfig.theme,
16
+ javascriptEnabled: true,
17
+ ...userConfig.lessLoader,
25
18
  },
26
19
  },
20
+ },
21
+ {
22
+ name: 'sass',
23
+ test: /\.(sass|scss)(\?.*)?$/,
24
+ loader: require.resolve('@umijs/bundler-webpack/compiled/sass-loader'),
25
+ loaderOptions: userConfig.sassLoader || {},
26
+ },
27
+ ];
28
+ for (const { name, test, loader, loaderOptions } of rulesConfig) {
29
+ const rule = config.module.rule(name);
30
+ const nestRulesConfig = [
31
+ userConfig.autoCSSModules && {
32
+ rule: rule
33
+ .test(test)
34
+ .oneOf('css-modules')
35
+ .resourceQuery(/modules/),
36
+ isCSSModules: true,
37
+ },
27
38
  {
28
- name: 'sass',
29
- test: /\.(sass|scss)(\?.*)?$/,
30
- loader: require.resolve('@umijs/bundler-webpack/compiled/sass-loader'),
31
- loaderOptions: userConfig.sassLoader || {},
39
+ rule: rule.test(test).oneOf('css').sideEffects(true),
40
+ isCSSModules: false,
32
41
  },
33
- ];
34
- for (const { name, test, loader, loaderOptions } of rulesConfig) {
35
- const rule = config.module.rule(name);
36
- const nestRulesConfig = [
37
- userConfig.autoCSSModules && {
38
- rule: rule
39
- .test(test)
40
- .oneOf('css-modules')
41
- .resourceQuery(/modules/),
42
- isCSSModules: true,
43
- },
44
- {
45
- rule: rule.test(test).oneOf('css').sideEffects(true),
46
- isCSSModules: false,
47
- },
48
- ].filter(Boolean);
49
- // @ts-ignore
50
- for (const { rule, isCSSModules } of nestRulesConfig) {
51
- if (userConfig.styleLoader) {
52
- rule
53
- .use('style-loader')
54
- .loader(require.resolve('@umijs/bundler-webpack/compiled/style-loader'))
55
- .options(Object.assign({ base: 0, esModule: true }, userConfig.styleLoader));
56
- }
57
- else {
58
- rule
59
- .use('mini-css-extract-plugin')
60
- .loader(require.resolve('@umijs/bundler-webpack/compiled/mini-css-extract-plugin/loader'))
61
- .options({
62
- publicPath: './',
63
- emit: true,
64
- esModule: true,
65
- });
66
- }
42
+ ].filter(Boolean);
43
+ // @ts-ignore
44
+ for (const { rule, isCSSModules } of nestRulesConfig) {
45
+ if (userConfig.styleLoader) {
67
46
  rule
68
- .use('css-loader')
69
- .loader(require.resolve('css-loader'))
70
- .options(Object.assign(Object.assign({ importLoaders: 1, esModule: true, url: true, import: true }, (isCSSModules
71
- ? {
72
- modules: Object.assign({ localIdentName: '[local]___[hash:base64:5]' }, userConfig.cssLoaderModules),
73
- }
74
- : {})), userConfig.cssLoader));
47
+ .use('style-loader')
48
+ .loader(require.resolve('@umijs/bundler-webpack/compiled/style-loader'))
49
+ .options({ base: 0, esModule: true, ...userConfig.styleLoader });
50
+ }
51
+ else {
75
52
  rule
76
- .use('postcss-loader')
77
- .loader(require.resolve('@umijs/bundler-webpack/compiled/postcss-loader'))
53
+ .use('mini-css-extract-plugin')
54
+ .loader(require.resolve('@umijs/bundler-webpack/compiled/mini-css-extract-plugin/loader'))
78
55
  .options({
79
- postcssOptions: Object.assign({ ident: 'postcss', plugins: [
80
- require('@umijs/bundler-webpack/compiled/postcss-flexbugs-fixes'),
81
- require('postcss-preset-env')({
82
- browsers: opts.browsers,
83
- autoprefixer: Object.assign({ flexbox: 'no-2009' }, userConfig.autoprefixer),
84
- stage: 3,
85
- }),
86
- ].concat(userConfig.extraPostCSSPlugins || []) }, userConfig.postcssLoader),
56
+ publicPath: './',
57
+ emit: true,
58
+ esModule: true,
87
59
  });
88
- if (loader) {
89
- rule
90
- .use(loader)
91
- .loader(typeof loader === 'string' ? require.resolve(loader) : loader)
92
- .options(loaderOptions || {});
93
- }
60
+ }
61
+ rule
62
+ .use('css-loader')
63
+ .loader(require.resolve('css-loader'))
64
+ .options({
65
+ importLoaders: 1,
66
+ esModule: true,
67
+ url: true,
68
+ import: true,
69
+ ...(isCSSModules
70
+ ? {
71
+ modules: {
72
+ localIdentName: '[local]___[hash:base64:5]',
73
+ ...userConfig.cssLoaderModules,
74
+ },
75
+ }
76
+ : {}),
77
+ ...userConfig.cssLoader,
78
+ });
79
+ rule
80
+ .use('postcss-loader')
81
+ .loader(require.resolve('@umijs/bundler-webpack/compiled/postcss-loader'))
82
+ .options({
83
+ postcssOptions: {
84
+ ident: 'postcss',
85
+ plugins: [
86
+ require('@umijs/bundler-webpack/compiled/postcss-flexbugs-fixes'),
87
+ require('postcss-preset-env')({
88
+ browsers: opts.browsers,
89
+ autoprefixer: {
90
+ flexbox: 'no-2009',
91
+ ...userConfig.autoprefixer,
92
+ },
93
+ stage: 3,
94
+ }),
95
+ ].concat(userConfig.extraPostCSSPlugins || []),
96
+ ...userConfig.postcssLoader,
97
+ },
98
+ });
99
+ if (loader) {
100
+ rule
101
+ .use(loader)
102
+ .loader(typeof loader === 'string' ? require.resolve(loader) : loader)
103
+ .options(loaderOptions || {});
94
104
  }
95
105
  }
96
- });
106
+ }
97
107
  }
98
108
  exports.addCSSRules = addCSSRules;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addDefinePlugin = exports.resolveDefine = void 0;
13
4
  const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
@@ -29,17 +20,18 @@ function resolveDefine(opts) {
29
20
  define[key] = JSON.stringify(opts.define[key]);
30
21
  }
31
22
  }
32
- return Object.assign({ 'process.env': env }, define);
23
+ return {
24
+ 'process.env': env,
25
+ ...define,
26
+ };
33
27
  }
34
28
  exports.resolveDefine = resolveDefine;
35
- function addDefinePlugin(opts) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- const { config, userConfig } = opts;
38
- config.plugin('define').use(webpack_1.DefinePlugin, [
39
- resolveDefine({
40
- define: userConfig.define || {},
41
- }),
42
- ]);
43
- });
29
+ async function addDefinePlugin(opts) {
30
+ const { config, userConfig } = opts;
31
+ config.plugin('define').use(webpack_1.DefinePlugin, [
32
+ resolveDefine({
33
+ define: userConfig.define || {},
34
+ }),
35
+ ]);
44
36
  }
45
37
  exports.addDefinePlugin = addDefinePlugin;
@@ -114,7 +114,7 @@ const logUnusedFiles = (unusedFiles) => {
114
114
  if (!(unusedFiles === null || unusedFiles === void 0 ? void 0 : unusedFiles.length)) {
115
115
  return;
116
116
  }
117
- console.log(utils_1.chalk.yellow.bold('\nWarning:'), utils_1.chalk.yellow(`There are ${unusedFiles.length} unused files:\n`), ...unusedFiles.map((file, index) => `${index + 1}. ${utils_1.chalk.yellow(file)}\n`), utils_1.chalk.red.bold('Please be careful if you want to remove them (¬º-°)¬.\n'));
117
+ console.log(utils_1.chalk.yellow.bold('\nWarning:'), utils_1.chalk.yellow(`There are ${unusedFiles.length} unused files:`), ...unusedFiles.map((file, index) => `\n${index + 1}. ${utils_1.chalk.yellow(file)}`), utils_1.chalk.red.bold('\nPlease be careful if you want to remove them (¬º-°)¬.\n'));
118
118
  };
119
119
  const convertToUnixPath = (path) => path.replace(/\\+/g, '/');
120
120
  exports.default = detectDeadCode;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -18,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
22
  __setModuleDefault(result, mod);
19
23
  return result;
20
24
  };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
25
  Object.defineProperty(exports, "__esModule", { value: true });
31
26
  exports.addDetectDeadCodePlugin = void 0;
32
27
  const types_1 = require("../types");
@@ -48,24 +43,28 @@ class DetectDeadCodePlugin {
48
43
  if (!options) {
49
44
  return;
50
45
  }
51
- this.options = Object.assign(Object.assign({}, this.options), options);
46
+ this.options = {
47
+ ...this.options,
48
+ ...options,
49
+ };
52
50
  }
53
51
  apply(compiler) {
54
52
  if (!this.options.context) {
55
- this.options = Object.assign(Object.assign({}, this.options), { context: compiler.context });
53
+ this.options = {
54
+ ...this.options,
55
+ context: compiler.context,
56
+ };
56
57
  }
57
58
  compiler.hooks.afterEmit.tapAsync('DetectDeadCodePlugin', this.handleAfterEmit);
58
59
  }
59
60
  }
60
- function addDetectDeadCodePlugin(opts) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const { config, userConfig } = opts;
63
- const isDev = opts.env === types_1.Env.development;
64
- if (userConfig.deadCode && !isDev) {
65
- config
66
- .plugin('detect-dead-code-plugin')
67
- .use(DetectDeadCodePlugin, [userConfig.deadCode]);
68
- }
69
- });
61
+ async function addDetectDeadCodePlugin(opts) {
62
+ const { config, userConfig } = opts;
63
+ const isDev = opts.env === types_1.Env.development;
64
+ if (userConfig.deadCode && !isDev) {
65
+ config
66
+ .plugin('detect-dead-code-plugin')
67
+ .use(DetectDeadCodePlugin, [userConfig.deadCode]);
68
+ }
70
69
  }
71
70
  exports.addDetectDeadCodePlugin = addDetectDeadCodePlugin;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -17,18 +8,16 @@ exports.addFastRefreshPlugin = void 0;
17
8
  const lib_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin/lib"));
18
9
  const constants_1 = require("../constants");
19
10
  const types_1 = require("../types");
20
- function addFastRefreshPlugin(opts) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const { config, userConfig, name } = opts;
23
- const isDev = opts.env === types_1.Env.development;
24
- const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== constants_1.MFSU_NAME;
25
- // TODO: Should only run in react csr
26
- if (useFastRefresh) {
27
- config
28
- .plugin('fastRefresh')
29
- .after('hmr')
30
- .use(lib_1.default, [{ overlay: false }]);
31
- }
32
- });
11
+ async function addFastRefreshPlugin(opts) {
12
+ const { config, userConfig, name } = opts;
13
+ const isDev = opts.env === types_1.Env.development;
14
+ const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== constants_1.MFSU_NAME;
15
+ // TODO: Should only run in react csr
16
+ if (useFastRefresh) {
17
+ config
18
+ .plugin('fastRefresh')
19
+ .after('hmr')
20
+ .use(lib_1.default, [{ overlay: false }]);
21
+ }
33
22
  }
34
23
  exports.addFastRefreshPlugin = addFastRefreshPlugin;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -15,20 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.addForkTSCheckerPlugin = void 0;
16
7
  // @ts-ignore
17
8
  const fork_ts_checker_webpack_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/fork-ts-checker-webpack-plugin"));
18
- function addForkTSCheckerPlugin(opts) {
9
+ async function addForkTSCheckerPlugin(opts) {
19
10
  var _a;
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const { config, userConfig } = opts;
22
- if (userConfig.forkTSChecker) {
23
- // use user's typescript
24
- if ((_a = userConfig.forkTSChecker.typescript) === null || _a === void 0 ? void 0 : _a.enable) {
25
- userConfig.forkTSChecker.typescript.typescriptPath =
26
- require.resolve('typescript');
27
- }
28
- config
29
- .plugin('fork-ts-checker-plugin')
30
- .use(fork_ts_checker_webpack_plugin_1.default, [userConfig.forkTSChecker]);
11
+ const { config, userConfig } = opts;
12
+ if (userConfig.forkTSChecker) {
13
+ // use user's typescript
14
+ if ((_a = userConfig.forkTSChecker.typescript) === null || _a === void 0 ? void 0 : _a.enable) {
15
+ userConfig.forkTSChecker.typescript.typescriptPath =
16
+ require.resolve('typescript');
31
17
  }
32
- });
18
+ config
19
+ .plugin('fork-ts-checker-plugin')
20
+ .use(fork_ts_checker_webpack_plugin_1.default, [userConfig.forkTSChecker]);
21
+ }
33
22
  }
34
23
  exports.addForkTSCheckerPlugin = addForkTSCheckerPlugin;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addHarmonyLinkingErrorPlugin = void 0;
13
4
  // ref: https://github.com/webpack/webpack/blob/ccecc17c01af96edddb931a76e7a3b21ef2969d8/lib/dependencies/HarmonyImportDependency.js#L164
@@ -33,10 +24,8 @@ class HarmonyLinkingErrorPlugin {
33
24
  });
34
25
  }
35
26
  }
36
- function addHarmonyLinkingErrorPlugin(opts) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const { config } = opts;
39
- config.plugin('harmony-linking-error-plugin').use(HarmonyLinkingErrorPlugin);
40
- });
27
+ async function addHarmonyLinkingErrorPlugin(opts) {
28
+ const { config } = opts;
29
+ config.plugin('harmony-linking-error-plugin').use(HarmonyLinkingErrorPlugin);
41
30
  }
42
31
  exports.addHarmonyLinkingErrorPlugin = addHarmonyLinkingErrorPlugin;
@@ -1,27 +1,16 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addIgnorePlugin = void 0;
13
4
  const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
14
- function addIgnorePlugin(opts) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const { config, userConfig } = opts;
17
- if (userConfig.ignoreMomentLocale) {
18
- config.plugin('ignore-moment-locale').use(webpack_1.IgnorePlugin, [
19
- {
20
- resourceRegExp: /^\.\/locale$/,
21
- contextRegExp: /moment$/,
22
- },
23
- ]);
24
- }
25
- });
5
+ 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
+ }
26
15
  }
27
16
  exports.addIgnorePlugin = addIgnorePlugin;
@@ -7,6 +7,7 @@ interface IOpts {
7
7
  env: Env;
8
8
  extraBabelPlugins: any[];
9
9
  extraBabelPresets: any[];
10
+ extraBabelIncludes: string[];
10
11
  extraEsbuildLoaderHandler: any[];
11
12
  babelPreset: any;
12
13
  name?: string;