@umijs/bundler-webpack 4.0.5 → 4.0.8

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 (67) hide show
  1. package/{dist → client}/client/client.d.ts +0 -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 -1
  8. package/dist/build.js +105 -61
  9. package/dist/cli.js +77 -69
  10. package/dist/config/_sampleFeature.js +33 -9
  11. package/dist/config/assetRules.js +45 -36
  12. package/dist/config/bundleAnalyzerPlugin.js +39 -17
  13. package/dist/config/compressPlugin.js +113 -95
  14. package/dist/config/config.d.ts +1 -0
  15. package/dist/config/config.js +204 -215
  16. package/dist/config/copyPlugin.js +58 -33
  17. package/dist/config/cssRules.js +136 -131
  18. package/dist/config/definePlugin.d.ts +1 -0
  19. package/dist/config/definePlugin.js +71 -31
  20. package/dist/config/detectDeadCode.js +120 -108
  21. package/dist/config/detectDeadCodePlugin.js +78 -63
  22. package/dist/config/fastRefreshPlugin.js +39 -20
  23. package/dist/config/forkTSCheckerPlugin.js +38 -19
  24. package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
  25. package/dist/config/ignorePlugin.js +38 -14
  26. package/dist/config/javaScriptRules.js +146 -173
  27. package/dist/config/manifestPlugin.js +51 -15
  28. package/dist/config/miniCSSExtractPlugin.js +42 -22
  29. package/dist/config/nodePolyfill.js +65 -26
  30. package/dist/config/nodePrefixPlugin.js +36 -12
  31. package/dist/config/progressPlugin.js +37 -13
  32. package/dist/config/purgecssWebpackPlugin.js +41 -19
  33. package/dist/config/speedMeasureWebpackPlugin.js +41 -20
  34. package/dist/config/ssrPlugin.js +83 -63
  35. package/dist/config/svgRules.js +74 -46
  36. package/dist/constants.js +57 -22
  37. package/dist/dev.d.ts +1 -1
  38. package/dist/dev.js +170 -129
  39. package/dist/index.d.ts +0 -2
  40. package/dist/index.js +22 -35
  41. package/dist/loader/svgr.js +73 -54
  42. package/dist/loader/swc.js +110 -69
  43. package/dist/parcelCSS.d.ts +2 -0
  44. package/dist/parcelCSS.js +32 -0
  45. package/dist/plugins/ProgressPlugin.js +66 -43
  46. package/dist/plugins/RuntimePublicPathPlugin.js +42 -23
  47. package/dist/plugins/_SamplePlugin.js +39 -14
  48. package/dist/requireHook.js +37 -27
  49. package/dist/schema.js +119 -95
  50. package/dist/server/server.d.ts +0 -1
  51. package/dist/server/server.js +214 -184
  52. package/dist/server/ws.d.ts +0 -2
  53. package/dist/server/ws.js +63 -38
  54. package/dist/swcPlugins/autoCSSModules.js +50 -31
  55. package/dist/swcPlugins/changeImportFromString.js +31 -9
  56. package/dist/swcPlugins/lockCoreJS.js +44 -20
  57. package/dist/types.js +61 -30
  58. package/dist/utils/browsersList.js +31 -8
  59. package/dist/utils/depMatch.js +63 -39
  60. package/dist/utils/formatWebpackMessages.js +93 -91
  61. package/dist/utils/getEsBuildTarget.js +32 -10
  62. package/package.json +9 -11
  63. package/compiled/fork-ts-checker-webpack-plugin/LICENSE +0 -21
  64. package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
  65. package/compiled/fork-ts-checker-webpack-plugin/index.js +0 -42
  66. package/compiled/fork-ts-checker-webpack-plugin/package.json +0 -1
  67. package/dist/client/client.js +0 -245
@@ -1,14 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addNodePrefixPlugin = 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
+ // nodePrefixPlugin.ts
20
+ var nodePrefixPlugin_exports = {};
21
+ __export(nodePrefixPlugin_exports, {
22
+ addNodePrefixPlugin: () => addNodePrefixPlugin
23
+ });
24
+ module.exports = __toCommonJS(nodePrefixPlugin_exports);
25
+ var import_webpack = require("@umijs/bundler-webpack/compiled/webpack");
5
26
  async function addNodePrefixPlugin(opts) {
6
- const { config } = opts;
7
- config.plugin('node-prefix-plugin').use(webpack_1.NormalModuleReplacementPlugin, [
8
- /^node:/,
9
- (resource) => {
10
- resource.request = resource.request.replace(/^node:/, '');
11
- },
12
- ]);
27
+ const { config } = opts;
28
+ config.plugin("node-prefix-plugin").use(import_webpack.NormalModuleReplacementPlugin, [
29
+ /^node:/,
30
+ (resource) => {
31
+ resource.request = resource.request.replace(/^node:/, "");
32
+ }
33
+ ]);
13
34
  }
14
- exports.addNodePrefixPlugin = addNodePrefixPlugin;
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ addNodePrefixPlugin
38
+ });
@@ -1,16 +1,40 @@
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.addProgressPlugin = void 0;
7
- const ProgressPlugin_1 = __importDefault(require("../plugins/ProgressPlugin"));
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
+ // progressPlugin.ts
23
+ var progressPlugin_exports = {};
24
+ __export(progressPlugin_exports, {
25
+ addProgressPlugin: () => addProgressPlugin
26
+ });
27
+ module.exports = __toCommonJS(progressPlugin_exports);
28
+ var import_ProgressPlugin = __toESM(require("../plugins/ProgressPlugin"));
8
29
  async function addProgressPlugin(opts) {
9
- const { config, name } = opts;
10
- config.plugin('progress-plugin').use(ProgressPlugin_1.default, [
11
- {
12
- name,
13
- },
14
- ]);
30
+ const { config, name } = opts;
31
+ config.plugin("progress-plugin").use(import_ProgressPlugin.default, [
32
+ {
33
+ name
34
+ }
35
+ ]);
15
36
  }
16
- exports.addProgressPlugin = addProgressPlugin;
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ addProgressPlugin
40
+ });
@@ -1,21 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyPurgeCSSWebpackPlugin = void 0;
4
- const types_1 = require("../types");
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
+ // purgecssWebpackPlugin.ts
20
+ var purgecssWebpackPlugin_exports = {};
21
+ __export(purgecssWebpackPlugin_exports, {
22
+ applyPurgeCSSWebpackPlugin: () => applyPurgeCSSWebpackPlugin
23
+ });
24
+ module.exports = __toCommonJS(purgecssWebpackPlugin_exports);
25
+ var import_types = require("../types");
5
26
  async function applyPurgeCSSWebpackPlugin(opts) {
6
- const { config, userConfig, cwd, env } = opts;
7
- config;
8
- userConfig;
9
- cwd;
10
- env;
11
- if (userConfig.purgeCSS && env === types_1.Env.production) {
12
- config
13
- .plugin('purgecss-webpack-plugin')
14
- .use(require('@umijs/bundler-webpack/compiled/purgecss-webpack-plugin'), [
15
- {
16
- paths: [],
17
- },
18
- ]);
19
- }
27
+ const { config, userConfig, cwd, env } = opts;
28
+ config;
29
+ userConfig;
30
+ cwd;
31
+ env;
32
+ if (userConfig.purgeCSS && env === import_types.Env.production) {
33
+ config.plugin("purgecss-webpack-plugin").use(require("@umijs/bundler-webpack/compiled/purgecss-webpack-plugin"), [
34
+ {
35
+ paths: []
36
+ }
37
+ ]);
38
+ }
20
39
  }
21
- exports.applyPurgeCSSWebpackPlugin = applyPurgeCSSWebpackPlugin;
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ applyPurgeCSSWebpackPlugin
43
+ });
@@ -1,23 +1,44 @@
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.addSpeedMeasureWebpackPlugin = void 0;
7
- // @ts-ignore
8
- const speed_measure_webpack_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/speed-measure-webpack-plugin"));
9
- const path_1 = require("path");
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
+ // speedMeasureWebpackPlugin.ts
23
+ var speedMeasureWebpackPlugin_exports = {};
24
+ __export(speedMeasureWebpackPlugin_exports, {
25
+ addSpeedMeasureWebpackPlugin: () => addSpeedMeasureWebpackPlugin
26
+ });
27
+ module.exports = __toCommonJS(speedMeasureWebpackPlugin_exports);
28
+ var import_speed_measure_webpack_plugin = __toESM(require("@umijs/bundler-webpack/compiled/speed-measure-webpack-plugin"));
29
+ var import_path = require("path");
10
30
  async function addSpeedMeasureWebpackPlugin(opts) {
11
- let webpackConfig = opts.webpackConfig;
12
- if (process.env.SPEED_MEASURE) {
13
- const smpOption = process.env.SPEED_MEASURE === 'JSON'
14
- ? {
15
- outputFormat: 'json',
16
- outputTarget: (0, path_1.join)(process.cwd(), 'SPEED_MEASURE.json'),
17
- }
18
- : { outputFormat: 'human', outputTarget: console.log };
19
- webpackConfig = new speed_measure_webpack_plugin_1.default(smpOption).wrap(webpackConfig);
20
- }
21
- return webpackConfig;
31
+ let webpackConfig = opts.webpackConfig;
32
+ if (process.env.SPEED_MEASURE) {
33
+ const smpOption = process.env.SPEED_MEASURE === "JSON" ? {
34
+ outputFormat: "json",
35
+ outputTarget: (0, import_path.join)(process.cwd(), "SPEED_MEASURE.json")
36
+ } : { outputFormat: "human", outputTarget: console.log };
37
+ webpackConfig = new import_speed_measure_webpack_plugin.default(smpOption).wrap(webpackConfig);
38
+ }
39
+ return webpackConfig;
22
40
  }
23
- exports.addSpeedMeasureWebpackPlugin = addSpeedMeasureWebpackPlugin;
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ addSpeedMeasureWebpackPlugin
44
+ });
@@ -1,66 +1,86 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
4
- const utils_1 = require("@umijs/utils");
5
- const fs_1 = require("fs");
6
- const path_1 = require("path");
7
- const constants_1 = require("../constants");
8
- const PLUGIN_NAME = 'SSR_PLUGIN';
9
- class SSRPlugin {
10
- constructor(opts) {
11
- this.opts = opts;
12
- this.manifest = new Map();
13
- }
14
- apply(compiler) {
15
- // ref: https://github.com/webdeveric/webpack-assets-manifest
16
- compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
17
- compilation.hooks.processAssets.tap(PLUGIN_NAME, () => {
18
- const publicPath = compiler.options.output.publicPath || '/';
19
- const assets = compilation.getAssets().filter((asset) => {
20
- if (asset.info.hotModuleReplacement) {
21
- return false;
22
- }
23
- return true;
24
- });
25
- assets.forEach((asset) => {
26
- if (asset.info.sourceFilename) {
27
- this.manifest.set(asset.info.sourceFilename, publicPath + asset.name);
28
- }
29
- });
30
- const stats = compilation.getStats().toJson({
31
- all: false,
32
- assets: true,
33
- cachedAssets: true,
34
- cachedModules: true,
35
- });
36
- const { assetsByChunkName } = stats;
37
- Object.keys(assetsByChunkName).forEach((chunkName) => {
38
- assetsByChunkName[chunkName].forEach((filename) => {
39
- const ext = (0, path_1.extname)(filename.split(/[?#]/)[0]);
40
- if (!filename.includes('.hot-update.')) {
41
- this.manifest.set(chunkName + ext, publicPath + filename);
42
- }
43
- });
44
- });
45
- const assetsSource = JSON.stringify({
46
- assets: Object.fromEntries(this.manifest),
47
- }, null, 2);
48
- if (process.env.NODE_ENV === 'production' ||
49
- this.opts.userConfig.writeToDisk) {
50
- compilation.emitAsset('build-manifest.json', new webpack_1.sources.RawSource(assetsSource, false));
51
- }
52
- else {
53
- const outputPath = compiler.options.output.path;
54
- utils_1.fsExtra.mkdirpSync(outputPath);
55
- (0, fs_1.writeFileSync)((0, path_1.join)(outputPath, 'build-manifest.json'), assetsSource, 'utf-8');
56
- }
57
- });
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
+ // ssrPlugin.ts
20
+ var ssrPlugin_exports = {};
21
+ __export(ssrPlugin_exports, {
22
+ default: () => addSSRPlugin
23
+ });
24
+ module.exports = __toCommonJS(ssrPlugin_exports);
25
+ var import_webpack = require("@umijs/bundler-webpack/compiled/webpack");
26
+ var import_utils = require("@umijs/utils");
27
+ var import_fs = require("fs");
28
+ var import_path = require("path");
29
+ var import_constants = require("../constants");
30
+ var PLUGIN_NAME = "SSR_PLUGIN";
31
+ var SSRPlugin = class {
32
+ constructor(opts) {
33
+ this.opts = opts;
34
+ this.manifest = /* @__PURE__ */ new Map();
35
+ }
36
+ apply(compiler) {
37
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
38
+ compilation.hooks.processAssets.tap(PLUGIN_NAME, () => {
39
+ const publicPath = compiler.options.output.publicPath || "/";
40
+ const assets = compilation.getAssets().filter((asset) => {
41
+ if (asset.info.hotModuleReplacement) {
42
+ return false;
43
+ }
44
+ return true;
58
45
  });
59
- }
60
- }
46
+ assets.forEach((asset) => {
47
+ if (asset.info.sourceFilename) {
48
+ this.manifest.set(asset.info.sourceFilename, publicPath + asset.name);
49
+ }
50
+ });
51
+ const stats = compilation.getStats().toJson({
52
+ all: false,
53
+ assets: true,
54
+ cachedAssets: true,
55
+ cachedModules: true
56
+ });
57
+ const { assetsByChunkName } = stats;
58
+ Object.keys(assetsByChunkName).forEach((chunkName) => {
59
+ assetsByChunkName[chunkName].forEach((filename) => {
60
+ const ext = (0, import_path.extname)(filename.split(/[?#]/)[0]);
61
+ if (!filename.includes(".hot-update.")) {
62
+ this.manifest.set(chunkName + ext, publicPath + filename);
63
+ }
64
+ });
65
+ });
66
+ const assetsSource = JSON.stringify({
67
+ assets: Object.fromEntries(this.manifest)
68
+ }, null, 2);
69
+ if (process.env.NODE_ENV === "production" || this.opts.userConfig.writeToDisk) {
70
+ compilation.emitAsset("build-manifest.json", new import_webpack.sources.RawSource(assetsSource, false));
71
+ } else {
72
+ const outputPath = compiler.options.output.path;
73
+ import_utils.fsExtra.mkdirpSync(outputPath);
74
+ (0, import_fs.writeFileSync)((0, import_path.join)(outputPath, "build-manifest.json"), assetsSource, "utf-8");
75
+ }
76
+ });
77
+ });
78
+ }
79
+ };
61
80
  function addSSRPlugin(opts) {
62
- if (opts.userConfig.ssr && opts.name !== constants_1.MFSU_NAME) {
63
- opts.config.plugin('ssr-plugin').use(SSRPlugin, [opts]);
64
- }
81
+ if (opts.userConfig.ssr && opts.name !== import_constants.MFSU_NAME) {
82
+ opts.config.plugin("ssr-plugin").use(SSRPlugin, [opts]);
83
+ }
65
84
  }
66
- exports.default = addSSRPlugin;
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {});
@@ -1,48 +1,76 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addSVGRules = void 0;
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,
23
- },
24
- },
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) {
39
- const svgRule = config.module.rule('svg');
40
- svgRule
41
- .test(/\.svg$/)
42
- .use('svgo-loader')
43
- .loader(require.resolve('@umijs/bundler-webpack/compiled/svgo-loader'))
44
- .options({ configFile: false, ...svgo })
45
- .end();
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]);
46
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
+ // svgRules.ts
40
+ var svgRules_exports = {};
41
+ __export(svgRules_exports, {
42
+ addSVGRules: () => addSVGRules
43
+ });
44
+ module.exports = __toCommonJS(svgRules_exports);
45
+ async function addSVGRules(opts) {
46
+ const { config, userConfig } = opts;
47
+ const { svgr, svgo = {} } = userConfig;
48
+ if (svgr) {
49
+ const svgrRule = config.module.rule("svgr");
50
+ svgrRule.test(/\.svg$/).issuer(/\.[jt]sx?$/).type("javascript/auto").use("svgr-loader").loader(require.resolve("../loader/svgr")).options(__spreadProps(__spreadValues({
51
+ svgoConfig: __spreadValues({
52
+ plugins: [
53
+ {
54
+ name: "preset-default",
55
+ params: {
56
+ overrides: {
57
+ removeTitle: false
58
+ }
59
+ }
60
+ },
61
+ "prefixIds"
62
+ ]
63
+ }, svgo)
64
+ }, svgr), {
65
+ svgo: !!svgo
66
+ })).end().use("url-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/url-loader")).end();
67
+ }
68
+ if (svgo !== false) {
69
+ const svgRule = config.module.rule("svg");
70
+ svgRule.test(/\.svg$/).use("svgo-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/svgo-loader")).options(__spreadValues({ configFile: false }, svgo)).end();
71
+ }
47
72
  }
48
- exports.addSVGRules = addSVGRules;
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ addSVGRules
76
+ });
package/dist/constants.js CHANGED
@@ -1,24 +1,59 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- exports.DEFAULT_DEVTOOL = 'cheap-module-source-map';
5
- exports.DEFAULT_OUTPUT_PATH = 'dist';
6
- exports.MFSU_NAME = 'MFSU';
7
- var MESSAGE_TYPE;
8
- (function (MESSAGE_TYPE) {
9
- MESSAGE_TYPE["ok"] = "ok";
10
- MESSAGE_TYPE["warnings"] = "warnings";
11
- MESSAGE_TYPE["errors"] = "errors";
12
- MESSAGE_TYPE["hash"] = "hash";
13
- MESSAGE_TYPE["stillOk"] = "still-ok";
14
- MESSAGE_TYPE["invalid"] = "invalid";
15
- })(MESSAGE_TYPE = exports.MESSAGE_TYPE || (exports.MESSAGE_TYPE = {}));
16
- exports.DEFAULT_BROWSER_TARGETS = {
17
- chrome: 80,
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 });
18
8
  };
19
- exports.DEFAULT_ESBUILD_TARGET_KEYS = [
20
- 'chrome',
21
- 'firefox',
22
- 'edge',
23
- 'safari',
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
+ // constants.ts
20
+ var constants_exports = {};
21
+ __export(constants_exports, {
22
+ DEFAULT_BROWSER_TARGETS: () => DEFAULT_BROWSER_TARGETS,
23
+ DEFAULT_DEVTOOL: () => DEFAULT_DEVTOOL,
24
+ DEFAULT_ESBUILD_TARGET_KEYS: () => DEFAULT_ESBUILD_TARGET_KEYS,
25
+ DEFAULT_OUTPUT_PATH: () => DEFAULT_OUTPUT_PATH,
26
+ MESSAGE_TYPE: () => MESSAGE_TYPE,
27
+ MFSU_NAME: () => MFSU_NAME
28
+ });
29
+ module.exports = __toCommonJS(constants_exports);
30
+ var DEFAULT_DEVTOOL = "cheap-module-source-map";
31
+ var DEFAULT_OUTPUT_PATH = "dist";
32
+ var MFSU_NAME = "MFSU";
33
+ var MESSAGE_TYPE = /* @__PURE__ */ ((MESSAGE_TYPE2) => {
34
+ MESSAGE_TYPE2["ok"] = "ok";
35
+ MESSAGE_TYPE2["warnings"] = "warnings";
36
+ MESSAGE_TYPE2["errors"] = "errors";
37
+ MESSAGE_TYPE2["hash"] = "hash";
38
+ MESSAGE_TYPE2["stillOk"] = "still-ok";
39
+ MESSAGE_TYPE2["invalid"] = "invalid";
40
+ return MESSAGE_TYPE2;
41
+ })(MESSAGE_TYPE || {});
42
+ var DEFAULT_BROWSER_TARGETS = {
43
+ chrome: 80
44
+ };
45
+ var DEFAULT_ESBUILD_TARGET_KEYS = [
46
+ "chrome",
47
+ "firefox",
48
+ "edge",
49
+ "safari"
24
50
  ];
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ DEFAULT_BROWSER_TARGETS,
54
+ DEFAULT_DEVTOOL,
55
+ DEFAULT_ESBUILD_TARGET_KEYS,
56
+ DEFAULT_OUTPUT_PATH,
57
+ MESSAGE_TYPE,
58
+ MFSU_NAME
59
+ });
package/dist/dev.d.ts CHANGED
@@ -22,7 +22,7 @@ declare type IOpts = {
22
22
  mfsuStrategy?: 'eager' | 'normal';
23
23
  mfsuInclude?: string[];
24
24
  srcCodeCache?: any;
25
- } & Pick<IConfigOpts, 'cache'>;
25
+ } & Pick<IConfigOpts, 'cache' | 'pkg'>;
26
26
  export declare function stripUndefined(obj: any): any;
27
27
  export declare function dev(opts: IOpts): Promise<void>;
28
28
  export {};