@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,57 +1,54 @@
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.addSVGRules = void 0;
13
- function addSVGRules(opts) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- const { config, userConfig } = opts;
16
- const { svgr, svgo = {} } = userConfig;
17
- if (svgr) {
18
- const svgrRule = config.module.rule('svgr');
19
- svgrRule
20
- .test(/\.svg$/)
21
- .issuer(/\.[jt]sx?$/)
22
- .type('javascript/auto')
23
- .use('svgr-loader')
24
- .loader(require.resolve('../loader/svgr'))
25
- .options(Object.assign(Object.assign({ svgoConfig: Object.assign({ plugins: [
26
- {
27
- name: 'preset-default',
28
- params: {
29
- overrides: {
30
- removeTitle: false,
31
- },
4
+ async function addSVGRules(opts) {
5
+ const { config, userConfig } = opts;
6
+ const { svgr, svgo = {} } = userConfig;
7
+ if (svgr) {
8
+ const svgrRule = config.module.rule('svgr');
9
+ svgrRule
10
+ .test(/\.svg$/)
11
+ .issuer(/\.[jt]sx?$/)
12
+ .type('javascript/auto')
13
+ .use('svgr-loader')
14
+ .loader(require.resolve('../loader/svgr'))
15
+ .options({
16
+ svgoConfig: {
17
+ plugins: [
18
+ {
19
+ name: 'preset-default',
20
+ params: {
21
+ overrides: {
22
+ removeTitle: false,
32
23
  },
33
24
  },
34
- ] }, svgo) }, svgr), { svgo: !!svgo }))
35
- .end()
36
- .use('url-loader')
37
- .loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'))
38
- .end();
39
- }
40
- if (svgo === false) {
41
- const svgRule = config.module.rule('svg');
42
- svgRule
43
- .test(/\.svg$/)
44
- .use('url-loader')
45
- .loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'));
46
- return;
47
- }
25
+ },
26
+ 'prefixIds',
27
+ ],
28
+ ...svgo,
29
+ },
30
+ ...svgr,
31
+ svgo: !!svgo,
32
+ })
33
+ .end()
34
+ .use('url-loader')
35
+ .loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'))
36
+ .end();
37
+ }
38
+ if (svgo === false) {
48
39
  const svgRule = config.module.rule('svg');
49
40
  svgRule
50
41
  .test(/\.svg$/)
51
- .use('svgo-loader')
52
- .loader(require.resolve('@umijs/bundler-webpack/compiled/svgo-loader'))
53
- .options(Object.assign({ configFile: false }, svgo))
54
- .end();
55
- });
42
+ .use('url-loader')
43
+ .loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'));
44
+ return;
45
+ }
46
+ const svgRule = config.module.rule('svg');
47
+ svgRule
48
+ .test(/\.svg$/)
49
+ .use('svgo-loader')
50
+ .loader(require.resolve('@umijs/bundler-webpack/compiled/svgo-loader'))
51
+ .options({ configFile: false, ...svgo })
52
+ .end();
56
53
  }
57
54
  exports.addSVGRules = addSVGRules;
@@ -12,3 +12,4 @@ export declare enum MESSAGE_TYPE {
12
12
  export declare const DEFAULT_BROWSER_TARGETS: {
13
13
  chrome: number;
14
14
  };
15
+ export declare const DEFAULT_ESBUILD_TARGET_KEYS: string[];
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_BROWSER_TARGETS = exports.MESSAGE_TYPE = exports.MFSU_NAME = exports.DEFAULT_OUTPUT_PATH = exports.DEFAULT_DEVTOOL = void 0;
3
+ exports.DEFAULT_ESBUILD_TARGET_KEYS = exports.DEFAULT_BROWSER_TARGETS = exports.MESSAGE_TYPE = exports.MFSU_NAME = exports.DEFAULT_OUTPUT_PATH = exports.DEFAULT_DEVTOOL = void 0;
4
4
  exports.DEFAULT_DEVTOOL = 'cheap-module-source-map';
5
5
  exports.DEFAULT_OUTPUT_PATH = 'dist';
6
6
  exports.MFSU_NAME = 'MFSU';
@@ -16,3 +16,9 @@ var MESSAGE_TYPE;
16
16
  exports.DEFAULT_BROWSER_TARGETS = {
17
17
  chrome: 80,
18
18
  };
19
+ exports.DEFAULT_ESBUILD_TARGET_KEYS = [
20
+ 'chrome',
21
+ 'firefox',
22
+ 'edge',
23
+ 'safari',
24
+ ];
package/dist/dev.d.ts CHANGED
@@ -4,6 +4,8 @@ declare type IOpts = {
4
4
  afterMiddlewares?: any[];
5
5
  beforeMiddlewares?: any[];
6
6
  onDevCompileDone?: Function;
7
+ onProgress?: Function;
8
+ onMFSUProgress?: Function;
7
9
  port?: number;
8
10
  host?: string;
9
11
  babelPreset?: any;
@@ -14,8 +16,10 @@ declare type IOpts = {
14
16
  extraBabelPlugins?: any[];
15
17
  extraBabelPresets?: any[];
16
18
  cwd: string;
19
+ rootDir?: string;
17
20
  config: IConfig;
18
21
  entry: Record<string, string>;
19
22
  } & Pick<IConfigOpts, 'cache'>;
23
+ export declare function stripUndefined(obj: any): any;
20
24
  export declare function dev(opts: IOpts): Promise<void>;
21
25
  export {};
package/dist/dev.js CHANGED
@@ -1,113 +1,134 @@
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
  };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.dev = void 0;
6
+ exports.dev = exports.stripUndefined = void 0;
16
7
  const mfsu_1 = require("@umijs/mfsu");
17
8
  const utils_1 = require("@umijs/utils");
9
+ const fs_1 = require("fs");
18
10
  const path_1 = require("path");
19
11
  const webpack_1 = __importDefault(require("../compiled/webpack"));
20
12
  const config_1 = require("./config/config");
21
13
  const constants_1 = require("./constants");
22
14
  const server_1 = require("./server/server");
23
15
  const types_1 = require("./types");
24
- function dev(opts) {
25
- var _a, _b, _c, _d, _e;
26
- var _f;
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const enableMFSU = opts.config.mfsu !== false;
29
- let mfsu = null;
30
- if (enableMFSU) {
31
- if (opts.config.srcTranspiler === types_1.Transpiler.swc) {
32
- utils_1.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
33
- }
34
- mfsu = new mfsu_1.MFSU({
35
- implementor: webpack_1.default,
36
- buildDepWithESBuild: (_a = opts.config.mfsu) === null || _a === void 0 ? void 0 : _a.esbuild,
37
- depBuildConfig: {
38
- extraPostCSSPlugins: ((_b = opts.config) === null || _b === void 0 ? void 0 : _b.extraPostCSSPlugins) || [],
39
- },
40
- mfName: (_c = opts.config.mfsu) === null || _c === void 0 ? void 0 : _c.mfName,
41
- runtimePublicPath: opts.config.runtimePublicPath,
42
- tmpBase: ((_d = opts.config.mfsu) === null || _d === void 0 ? void 0 : _d.cacheDirectory) ||
43
- (0, path_1.join)(opts.cwd, 'node_modules/.cache/mfsu'),
44
- getCacheDependency() {
45
- var _a;
46
- return {
47
- version: require('../package.json').version,
48
- esbuildMode: !!((_a = opts.config.mfsu) === null || _a === void 0 ? void 0 : _a.esbuild),
49
- };
50
- },
51
- });
16
+ function stripUndefined(obj) {
17
+ Object.keys(obj).forEach((key) => {
18
+ if (obj[key] === undefined) {
19
+ delete obj[key];
52
20
  }
53
- const webpackConfig = yield (0, config_1.getConfig)({
54
- cwd: opts.cwd,
55
- env: types_1.Env.development,
56
- entry: opts.entry,
57
- userConfig: opts.config,
58
- babelPreset: opts.babelPreset,
59
- extraBabelPlugins: [
60
- ...(opts.beforeBabelPlugins || []),
61
- ...((mfsu === null || mfsu === void 0 ? void 0 : mfsu.getBabelPlugins()) || []),
62
- ...(opts.extraBabelPlugins || []),
63
- ],
64
- extraBabelPresets: [
65
- ...(opts.beforeBabelPresets || []),
66
- ...(opts.extraBabelPresets || []),
67
- ],
68
- extraEsbuildLoaderHandler: (mfsu === null || mfsu === void 0 ? void 0 : mfsu.getEsbuildLoaderHandler()) || [],
69
- chainWebpack: opts.chainWebpack,
70
- modifyWebpackConfig: opts.modifyWebpackConfig,
71
- hmr: true,
72
- analyze: process.env.ANALYZE,
73
- cache: opts.cache,
74
- });
75
- const depConfig = yield (0, config_1.getConfig)({
76
- cwd: opts.cwd,
77
- env: types_1.Env.development,
78
- entry: opts.entry,
79
- userConfig: opts.config,
80
- hash: true,
81
- staticPathPrefix: mfsu_1.MF_DEP_PREFIX,
82
- name: constants_1.MFSU_NAME,
83
- cache: {
84
- buildDependencies: (_e = opts.cache) === null || _e === void 0 ? void 0 : _e.buildDependencies,
85
- cacheDirectory: (0, path_1.join)(opts.cwd, 'node_modules', '.cache', 'mfsu-deps'),
21
+ });
22
+ return obj;
23
+ }
24
+ exports.stripUndefined = stripUndefined;
25
+ async function dev(opts) {
26
+ var _a, _b, _c, _d, _e, _f;
27
+ var _g;
28
+ const enableMFSU = opts.config.mfsu !== false;
29
+ let mfsu = null;
30
+ if (enableMFSU) {
31
+ if (opts.config.srcTranspiler === types_1.Transpiler.swc) {
32
+ utils_1.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
33
+ }
34
+ mfsu = new mfsu_1.MFSU({
35
+ implementor: webpack_1.default,
36
+ buildDepWithESBuild: (_a = opts.config.mfsu) === null || _a === void 0 ? void 0 : _a.esbuild,
37
+ depBuildConfig: {
38
+ extraPostCSSPlugins: ((_b = opts.config) === null || _b === void 0 ? void 0 : _b.extraPostCSSPlugins) || [],
39
+ },
40
+ mfName: (_c = opts.config.mfsu) === null || _c === void 0 ? void 0 : _c.mfName,
41
+ runtimePublicPath: opts.config.runtimePublicPath,
42
+ tmpBase: ((_d = opts.config.mfsu) === null || _d === void 0 ? void 0 : _d.cacheDirectory) ||
43
+ (0, path_1.join)(opts.rootDir || opts.cwd, 'node_modules/.cache/mfsu'),
44
+ onMFSUProgress: opts.onMFSUProgress,
45
+ getCacheDependency() {
46
+ return stripUndefined({
47
+ version: require('../package.json').version,
48
+ mfsu: opts.config.mfsu,
49
+ alias: opts.config.alias,
50
+ externals: opts.config.externals,
51
+ theme: opts.config.theme,
52
+ runtimePublicPath: opts.config.runtimePublicPath,
53
+ publicPath: opts.config.publicPath,
54
+ });
86
55
  },
87
56
  });
88
- (_f = webpackConfig.resolve).alias || (_f.alias = {});
89
- // TODO: REMOVE ME
90
- ['@umijs/utils/compiled/strip-ansi', 'react-error-overlay'].forEach((dep) => {
91
- // @ts-ignore
92
- webpackConfig.resolve.alias[dep] = require.resolve(dep);
93
- });
94
- yield (mfsu === null || mfsu === void 0 ? void 0 : mfsu.setWebpackConfig({
95
- config: webpackConfig,
96
- depConfig: depConfig,
97
- }));
98
- yield (0, server_1.createServer)({
99
- webpackConfig,
100
- userConfig: opts.config,
101
- cwd: opts.cwd,
102
- beforeMiddlewares: [
103
- ...((mfsu === null || mfsu === void 0 ? void 0 : mfsu.getMiddlewares()) || []),
104
- ...(opts.beforeMiddlewares || []),
105
- ],
106
- port: opts.port,
107
- host: opts.host,
108
- afterMiddlewares: [...(opts.afterMiddlewares || [])],
109
- onDevCompileDone: opts.onDevCompileDone,
110
- });
57
+ }
58
+ const webpackConfig = await (0, config_1.getConfig)({
59
+ cwd: opts.cwd,
60
+ rootDir: opts.rootDir,
61
+ env: types_1.Env.development,
62
+ entry: opts.entry,
63
+ userConfig: opts.config,
64
+ babelPreset: opts.babelPreset,
65
+ extraBabelPlugins: [
66
+ ...(opts.beforeBabelPlugins || []),
67
+ ...((mfsu === null || mfsu === void 0 ? void 0 : mfsu.getBabelPlugins()) || []),
68
+ ...(opts.extraBabelPlugins || []),
69
+ ],
70
+ extraBabelPresets: [
71
+ ...(opts.beforeBabelPresets || []),
72
+ ...(opts.extraBabelPresets || []),
73
+ ],
74
+ extraBabelIncludes: opts.config.extraBabelIncludes,
75
+ extraEsbuildLoaderHandler: (mfsu === null || mfsu === void 0 ? void 0 : mfsu.getEsbuildLoaderHandler()) || [],
76
+ chainWebpack: opts.chainWebpack,
77
+ modifyWebpackConfig: opts.modifyWebpackConfig,
78
+ hmr: true,
79
+ analyze: process.env.ANALYZE,
80
+ cache: opts.cache,
81
+ });
82
+ const depConfig = await (0, config_1.getConfig)({
83
+ cwd: opts.cwd,
84
+ rootDir: opts.rootDir,
85
+ env: types_1.Env.development,
86
+ entry: opts.entry,
87
+ userConfig: opts.config,
88
+ hash: true,
89
+ staticPathPrefix: mfsu_1.MF_DEP_PREFIX,
90
+ name: constants_1.MFSU_NAME,
91
+ chainWebpack: (_e = opts.config.mfsu) === null || _e === void 0 ? void 0 : _e.chainWebpack,
92
+ cache: {
93
+ buildDependencies: (_f = opts.cache) === null || _f === void 0 ? void 0 : _f.buildDependencies,
94
+ cacheDirectory: (0, path_1.join)(opts.rootDir || opts.cwd, 'node_modules', '.cache', 'mfsu-deps'),
95
+ },
96
+ });
97
+ (_g = webpackConfig.resolve).alias || (_g.alias = {});
98
+ // TODO: REMOVE ME
99
+ ['@umijs/utils/compiled/strip-ansi', 'react-error-overlay'].forEach((dep) => {
100
+ // @ts-ignore
101
+ webpackConfig.resolve.alias[dep] = require.resolve(dep);
102
+ });
103
+ await (mfsu === null || mfsu === void 0 ? void 0 : mfsu.setWebpackConfig({
104
+ config: webpackConfig,
105
+ depConfig: depConfig,
106
+ }));
107
+ if (mfsu &&
108
+ webpackConfig.cache &&
109
+ typeof webpackConfig.cache === 'object' &&
110
+ webpackConfig.cache.type === 'filesystem') {
111
+ const webpackCachePath = (0, path_1.join)(webpackConfig.cache.cacheDirectory, `default-development`, 'index.pack');
112
+ const mfsuCacheExists = (0, fs_1.existsSync)(mfsu.depInfo.cacheFilePath);
113
+ const webpackCacheExists = (0, fs_1.existsSync)(webpackCachePath);
114
+ if (webpackCacheExists && !mfsuCacheExists) {
115
+ utils_1.logger.warn(`Invalidate webpack cache since mfsu cache is missing`);
116
+ utils_1.rimraf.sync(webpackConfig.cache.cacheDirectory);
117
+ }
118
+ }
119
+ await (0, server_1.createServer)({
120
+ webpackConfig,
121
+ userConfig: opts.config,
122
+ cwd: opts.cwd,
123
+ beforeMiddlewares: [
124
+ ...((mfsu === null || mfsu === void 0 ? void 0 : mfsu.getMiddlewares()) || []),
125
+ ...(opts.beforeMiddlewares || []),
126
+ ],
127
+ port: opts.port,
128
+ host: opts.host,
129
+ afterMiddlewares: [...(opts.afterMiddlewares || [])],
130
+ onDevCompileDone: opts.onDevCompileDone,
131
+ onProgress: opts.onProgress,
111
132
  });
112
133
  }
113
134
  exports.dev = dev;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- export type { RequestHandler } from '../compiled/express';
1
+ import type webpack from '../compiled/webpack';
2
+ export type { RequestHandler } from '@umijs/bundler-utils/compiled/express';
3
+ export type { Compiler, Stats } from '../compiled/webpack';
2
4
  export * from './build';
3
5
  export * from './config/config';
4
6
  export * from './dev';
5
7
  export * from './schema';
8
+ export { webpack };
package/dist/index.js CHANGED
@@ -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];
@@ -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
  };
@@ -22,9 +13,9 @@ const plugin_svgo_1 = __importDefault(require("@svgr/plugin-svgo"));
22
13
  const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
23
14
  const path_1 = require("path");
24
15
  const util_1 = require("util");
25
- const tranformSvg = (0, util_1.callbackify)((contents, options, state) => __awaiter(void 0, void 0, void 0, function* () {
26
- const jsCode = yield (0, core_1.transform)(contents, options, state);
27
- const result = yield (0, esbuild_1.transform)(jsCode, {
16
+ const tranformSvg = (0, util_1.callbackify)(async (contents, options, state) => {
17
+ const jsCode = await (0, core_1.transform)(contents, options, state);
18
+ const result = await (0, esbuild_1.transform)(jsCode, {
28
19
  loader: 'tsx',
29
20
  target: 'es2015',
30
21
  });
@@ -32,7 +23,7 @@ const tranformSvg = (0, util_1.callbackify)((contents, options, state) => __awai
32
23
  throw new Error(`Error while transforming using Esbuild`);
33
24
  }
34
25
  return result.code;
35
- }));
26
+ });
36
27
  function svgrLoader(contents) {
37
28
  this.cacheable && this.cacheable();
38
29
  const callback = this.async();
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  const core_1 = require("@swc/core");
15
4
  const types_1 = require("../types");
@@ -54,11 +43,17 @@ function swcLoader(contents) {
54
43
  // 启用异步模式
55
44
  const callback = this.async();
56
45
  const loaderOpts = this.getOptions();
57
- const { sync = false, parseMap = false } = loaderOpts, otherOpts = __rest(loaderOpts, ["sync", "parseMap"]);
46
+ const { sync = false, parseMap = false, ...otherOpts } = loaderOpts;
58
47
  const filename = this.resourcePath;
59
- const swcOpts = Object.assign(Object.assign(Object.assign({}, getBaseOpts({
48
+ const swcOpts = {
49
+ ...getBaseOpts({
50
+ filename,
51
+ }),
60
52
  filename,
61
- })), { filename, sourceMaps: this.sourceMap, sourceFileName: filename }), otherOpts);
53
+ sourceMaps: this.sourceMap,
54
+ sourceFileName: filename,
55
+ ...otherOpts,
56
+ };
62
57
  try {
63
58
  if (sync) {
64
59
  const output = (0, core_1.transformSync)(contents, swcOpts);
@@ -13,7 +13,7 @@ class UmiProgressPlugin extends webpack_1.ProgressPlugin {
13
13
  }
14
14
  apply(compiler) {
15
15
  compiler.hooks.invalid.tap(PLUGIN_NAME, () => {
16
- utils_1.logger.wait('compiling...');
16
+ utils_1.logger.wait('Compiling...');
17
17
  });
18
18
  compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {
19
19
  const { errors, warnings } = stats.toJson({
@@ -33,7 +33,7 @@ class UmiProgressPlugin extends webpack_1.ProgressPlugin {
33
33
  }
34
34
  else {
35
35
  const prefix = this.options.name ? `${this.options.name} ` : '';
36
- utils_1.logger.event(`${prefix}compiled successfully in ${stats.endTime - stats.startTime} ms (${stats.compilation.modules.size} modules)`);
36
+ utils_1.logger.event(`${prefix}Compiled successfully in ${stats.endTime - stats.startTime} ms (${stats.compilation.modules.size} modules)`);
37
37
  }
38
38
  });
39
39
  }
@@ -10,8 +10,11 @@ class RuntimePublicPathPlugin {
10
10
  // The hook to get the public path ('__webpack_require__.p')
11
11
  // https://github.com/webpack/webpack/blob/master/lib/runtime/PublicPathRuntimeModule.js
12
12
  if (module.constructor.name === 'PublicPathRuntimeModule') {
13
+ // If current public path is handled by mini-css-extract-plugin, skip it
14
+ if (module.getGeneratedCode().includes('webpack:///mini-css-extract-plugin'))
15
+ return;
13
16
  // @ts-ignore
14
- module._cachedGeneratedCode = `__webpack_require__.p = window.publicPath;`;
17
+ module._cachedGeneratedCode = `__webpack_require__.p = (globalThis || window).publicPath || '/';`;
15
18
  }
16
19
  });
17
20
  });
package/dist/schema.js CHANGED
@@ -4,18 +4,30 @@ exports.getSchemas = void 0;
4
4
  const types_1 = require("./types");
5
5
  const options = [
6
6
  'cheap-source-map',
7
- 'cheap-eval-source-map',
8
- 'cheap-hidden-source-map',
9
- 'cheap-inline-source-map',
10
7
  'cheap-module-source-map',
11
- 'cheap-module-eval-source-map',
12
- 'cheap-module-hidden-source-map',
13
- 'cheap-module-inline-source-map',
14
8
  'eval',
15
9
  'eval-source-map',
10
+ 'eval-cheap-source-map',
11
+ 'eval-cheap-module-source-map',
12
+ 'eval-nosources-cheap-source-map',
13
+ 'eval-nosources-cheap-module-source-map',
14
+ 'eval-nosources-source-map',
16
15
  'source-map',
17
16
  'hidden-source-map',
17
+ 'hidden-nosources-cheap-source-map',
18
+ 'hidden-nosources-cheap-module-source-map',
19
+ 'hidden-nosources-source-map',
20
+ 'hidden-cheap-source-map',
21
+ 'hidden-cheap-module-source-map',
18
22
  'inline-source-map',
23
+ 'inline-cheap-source-map',
24
+ 'inline-cheap-module-source-map',
25
+ 'inline-nosources-cheap-source-map',
26
+ 'inline-nosources-cheap-module-source-map',
27
+ 'inline-nosources-source-map',
28
+ 'nosources-source-map',
29
+ 'nosources-cheap-source-map',
30
+ 'nosources-cheap-module-source-map',
19
31
  ];
20
32
  const DEVTOOL_REGEX = new RegExp('^' + // start of string
21
33
  '(#@|@|#)?' + // maybe one of the pragmas
@@ -32,19 +44,22 @@ function getSchemas() {
32
44
  }), Joi.string())),
33
45
  cssLoader: (Joi) => Joi.object(),
34
46
  cssLoaderModules: (Joi) => Joi.object(),
35
- cssMinifier: (Joi) => Joi.string().valid(types_1.CSSMinifier.cssnano, types_1.CSSMinifier.esbuild, types_1.CSSMinifier.none),
47
+ cssMinifier: (Joi) => Joi.string().valid(types_1.CSSMinifier.cssnano, types_1.CSSMinifier.esbuild, types_1.CSSMinifier.parcelCSS, types_1.CSSMinifier.none),
36
48
  cssMinifierOptions: (Joi) => Joi.object(),
37
- define: (Joi) => Joi.object(),
38
49
  deadCode: (Joi) => Joi.object(),
50
+ define: (Joi) => Joi.object(),
39
51
  depTranspiler: (Joi) => Joi.string().valid(types_1.Transpiler.babel, types_1.Transpiler.esbuild, types_1.Transpiler.swc, types_1.Transpiler.none),
40
52
  devtool: (Joi) => Joi.alternatives().try(Joi.string().regex(DEVTOOL_REGEX), Joi.boolean()),
53
+ esm: (Joi) => Joi.object(),
41
54
  externals: (Joi) => Joi.alternatives().try(Joi.object(), Joi.string(), Joi.func()),
42
- extraBabelPlugins: (Joi) => Joi.alternatives().try(Joi.string(), Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.object()))),
43
- extraBabelPresets: (Joi) => Joi.alternatives().try(Joi.string(), Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.object()))),
55
+ extraBabelIncludes: (Joi) => Joi.array().items(Joi.string()),
56
+ extraBabelPlugins: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.array())),
57
+ extraBabelPresets: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.array())),
44
58
  extraPostCSSPlugins: (Joi) => Joi.array(),
45
59
  fastRefresh: (Joi) => Joi.boolean(),
46
60
  forkTSChecker: (Joi) => Joi.object(),
47
61
  hash: (Joi) => Joi.boolean(),
62
+ https: (Joi) => Joi.object(),
48
63
  ignoreMomentLocale: (Joi) => Joi.boolean(),
49
64
  inlineLimit: (Joi) => Joi.number(),
50
65
  jsMinifier: (Joi) => Joi.string().valid(types_1.JSMinifier.esbuild, types_1.JSMinifier.swc, types_1.JSMinifier.terser, types_1.JSMinifier.uglifyJs, types_1.JSMinifier.none),
@@ -57,8 +72,10 @@ function getSchemas() {
57
72
  }),
58
73
  mfsu: (Joi) => Joi.alternatives(Joi.object({
59
74
  cacheDirectory: Joi.string(),
75
+ chainWebpack: Joi.function(),
60
76
  esbuild: Joi.boolean(),
61
77
  mfName: Joi.string(),
78
+ runtimePublicPath: Joi.boolean(),
62
79
  }), Joi.boolean()),
63
80
  outputPath: (Joi) => Joi.string(),
64
81
  postcssLoader: (Joi) => Joi.object(),
@@ -69,12 +86,11 @@ function getSchemas() {
69
86
  sassLoader: (Joi) => Joi.object(),
70
87
  srcTranspiler: (Joi) => Joi.string().valid(types_1.Transpiler.babel, types_1.Transpiler.esbuild, types_1.Transpiler.swc, types_1.Transpiler.none),
71
88
  styleLoader: (Joi) => Joi.object(),
72
- svgr: (Joi) => Joi.object(),
73
89
  svgo: (Joi) => Joi.alternatives().try(Joi.object(), Joi.boolean()),
90
+ svgr: (Joi) => Joi.object(),
74
91
  targets: (Joi) => Joi.object(),
75
- writeToDisk: (Joi) => Joi.boolean(),
76
- esm: (Joi) => Joi.object(),
77
92
  theme: (Joi) => Joi.object(),
93
+ writeToDisk: (Joi) => Joi.boolean(),
78
94
  };
79
95
  }
80
96
  exports.getSchemas = getSchemas;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Configuration } from '@umijs/bundler-webpack/compiled/webpack';
3
4
  import http from 'http';
4
5
  import { IConfig } from '../types';
@@ -11,6 +12,7 @@ interface IOpts {
11
12
  beforeMiddlewares?: any[];
12
13
  afterMiddlewares?: any[];
13
14
  onDevCompileDone?: Function;
15
+ onProgress?: Function;
14
16
  }
15
- export declare function createServer(opts: IOpts): Promise<http.Server>;
17
+ export declare function createServer(opts: IOpts): Promise<http.Server | import("https").Server | null>;
16
18
  export {};