@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,74 +1,115 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@swc/core");
4
- const types_1 = require("../types");
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 __objRest = (source, exclude) => {
23
+ var target = {};
24
+ for (var prop in source)
25
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
+ target[prop] = source[prop];
27
+ if (source != null && __getOwnPropSymbols)
28
+ for (var prop of __getOwnPropSymbols(source)) {
29
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
+ target[prop] = source[prop];
31
+ }
32
+ return target;
33
+ };
34
+ var __export = (target, all) => {
35
+ for (var name in all)
36
+ __defProp(target, name, { get: all[name], enumerable: true });
37
+ };
38
+ var __copyProps = (to, from, except, desc) => {
39
+ if (from && typeof from === "object" || typeof from === "function") {
40
+ for (let key of __getOwnPropNames(from))
41
+ if (!__hasOwnProp.call(to, key) && key !== except)
42
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
43
+ }
44
+ return to;
45
+ };
46
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
47
+
48
+ // swc.ts
49
+ var swc_exports = {};
50
+ __export(swc_exports, {
51
+ default: () => swc_default
52
+ });
53
+ module.exports = __toCommonJS(swc_exports);
54
+ var import_core = require("@swc/core");
55
+ var import_types = require("../types");
5
56
  function getBaseOpts({ filename }) {
6
- const isTSFile = filename.endsWith('.ts');
7
- const isTypeScript = isTSFile || filename.endsWith('.tsx');
8
- const isDev = process.env.NODE_ENV === types_1.Env.development;
9
- /**
10
- * Not use swc auto polyfill , depend on `preset-umi/features/polyfill/polyfill` imported polyfill file
11
- *
12
- * @issue https://github.com/swc-project/swc/issues/2607
13
- * https://github.com/swc-project/swc/issues/1604
14
- */
15
- const swcOpts = {
16
- module: {
17
- // @ts-ignore
18
- type: 'es6',
19
- ignoreDynamic: true,
20
- },
21
- jsc: {
22
- parser: {
23
- syntax: isTypeScript ? 'typescript' : 'ecmascript',
24
- [isTypeScript ? 'tsx' : 'jsx']: !isTSFile,
25
- dynamicImport: isTypeScript,
26
- },
27
- target: 'es2015',
28
- transform: {
29
- react: {
30
- runtime: 'automatic',
31
- pragma: 'React.createElement',
32
- pragmaFrag: 'React.Fragment',
33
- throwIfNamespace: true,
34
- development: isDev,
35
- useBuiltins: true,
36
- },
37
- },
38
- },
39
- };
40
- return swcOpts;
41
- }
42
- function swcLoader(contents) {
43
- // 启用异步模式
44
- const callback = this.async();
45
- const loaderOpts = this.getOptions();
46
- const { sync = false, parseMap = false, ...otherOpts } = loaderOpts;
47
- const filename = this.resourcePath;
48
- const swcOpts = {
49
- ...getBaseOpts({
50
- filename,
51
- }),
52
- filename,
53
- sourceMaps: this.sourceMap,
54
- sourceFileName: filename,
55
- ...otherOpts,
56
- };
57
- try {
58
- if (sync) {
59
- const output = (0, core_1.transformSync)(contents, swcOpts);
60
- callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
61
- }
62
- else {
63
- (0, core_1.transform)(contents, swcOpts).then((output) => {
64
- callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
65
- }, (err) => {
66
- callback(err);
67
- });
57
+ const isTSFile = filename.endsWith(".ts");
58
+ const isTypeScript = isTSFile || filename.endsWith(".tsx");
59
+ const isDev = process.env.NODE_ENV === import_types.Env.development;
60
+ const swcOpts = {
61
+ module: {
62
+ type: "es6",
63
+ ignoreDynamic: true
64
+ },
65
+ jsc: {
66
+ parser: {
67
+ syntax: isTypeScript ? "typescript" : "ecmascript",
68
+ [isTypeScript ? "tsx" : "jsx"]: !isTSFile,
69
+ dynamicImport: isTypeScript
70
+ },
71
+ target: "es2015",
72
+ transform: {
73
+ react: {
74
+ runtime: "automatic",
75
+ pragma: "React.createElement",
76
+ pragmaFrag: "React.Fragment",
77
+ throwIfNamespace: true,
78
+ development: isDev,
79
+ useBuiltins: true
68
80
  }
81
+ }
69
82
  }
70
- catch (e) {
71
- callback(e);
83
+ };
84
+ return swcOpts;
85
+ }
86
+ function swcLoader(contents) {
87
+ const callback = this.async();
88
+ const loaderOpts = this.getOptions();
89
+ const _a = loaderOpts, { sync = false, parseMap = false } = _a, otherOpts = __objRest(_a, ["sync", "parseMap"]);
90
+ const filename = this.resourcePath;
91
+ const swcOpts = __spreadValues(__spreadProps(__spreadValues({}, getBaseOpts({
92
+ filename
93
+ })), {
94
+ filename,
95
+ sourceMaps: this.sourceMap,
96
+ sourceFileName: filename
97
+ }), otherOpts);
98
+ try {
99
+ if (sync) {
100
+ const output = (0, import_core.transformSync)(contents, swcOpts);
101
+ callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
102
+ } else {
103
+ (0, import_core.transform)(contents, swcOpts).then((output) => {
104
+ callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
105
+ }, (err) => {
106
+ callback(err);
107
+ });
72
108
  }
109
+ } catch (e) {
110
+ callback(e);
111
+ }
73
112
  }
74
- exports.default = swcLoader;
113
+ var swc_default = swcLoader;
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {});
@@ -0,0 +1,2 @@
1
+ import * as parcelCSS from '@parcel/css';
2
+ export { parcelCSS };
@@ -0,0 +1,32 @@
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
+ // parcelCSS.ts
23
+ var parcelCSS_exports = {};
24
+ __export(parcelCSS_exports, {
25
+ parcelCSS: () => parcelCSS
26
+ });
27
+ module.exports = __toCommonJS(parcelCSS_exports);
28
+ var parcelCSS = __toESM(require("@parcel/css"));
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ parcelCSS
32
+ });
@@ -1,44 +1,67 @@
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 PLUGIN_NAME = 'ProgressPlugin';
6
- class UmiProgressPlugin extends webpack_1.ProgressPlugin {
7
- constructor(options = {}) {
8
- super({ activeModules: true });
9
- this.options = options;
10
- this.handler = (percent, message, ...details) => {
11
- this.updateProgress({ percent, message, details });
12
- };
13
- }
14
- apply(compiler) {
15
- const prefix = this.options.name ? `[${this.options.name}]` : '[Webpack]';
16
- compiler.hooks.invalid.tap(PLUGIN_NAME, () => {
17
- utils_1.logger.wait(`${prefix} Compiling...`);
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
+ // ProgressPlugin.ts
20
+ var ProgressPlugin_exports = {};
21
+ __export(ProgressPlugin_exports, {
22
+ default: () => ProgressPlugin_default
23
+ });
24
+ module.exports = __toCommonJS(ProgressPlugin_exports);
25
+ var import_webpack = require("@umijs/bundler-webpack/compiled/webpack");
26
+ var import_utils = require("@umijs/utils");
27
+ var PLUGIN_NAME = "ProgressPlugin";
28
+ var UmiProgressPlugin = class extends import_webpack.ProgressPlugin {
29
+ constructor(options = {}) {
30
+ super({ activeModules: true });
31
+ this.options = options;
32
+ this.handler = (percent, message, ...details) => {
33
+ this.updateProgress({ percent, message, details });
34
+ };
35
+ }
36
+ apply(compiler) {
37
+ const prefix = this.options.name ? `[${this.options.name}]` : "[Webpack]";
38
+ compiler.hooks.invalid.tap(PLUGIN_NAME, () => {
39
+ import_utils.logger.wait(`${prefix} Compiling...`);
40
+ });
41
+ compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {
42
+ const { errors, warnings } = stats.toJson({
43
+ all: false,
44
+ warnings: true,
45
+ errors: true,
46
+ colors: true
47
+ });
48
+ const hasErrors = !!(errors == null ? void 0 : errors.length);
49
+ const hasWarnings = !!(warnings == null ? void 0 : warnings.length);
50
+ hasWarnings;
51
+ if (hasErrors) {
52
+ errors.forEach((error) => {
53
+ import_utils.logger.error(`${error.moduleName}${error.loc ? `:${error.loc}` : ""}`);
54
+ console.log(error.message);
18
55
  });
19
- compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {
20
- const { errors, warnings } = stats.toJson({
21
- all: false,
22
- warnings: true,
23
- errors: true,
24
- colors: true,
25
- });
26
- const hasErrors = !!(errors === null || errors === void 0 ? void 0 : errors.length);
27
- const hasWarnings = !!(warnings === null || warnings === void 0 ? void 0 : warnings.length);
28
- hasWarnings;
29
- if (hasErrors) {
30
- errors.forEach((error) => {
31
- utils_1.logger.error(`${error.moduleName}${error.loc ? `:${error.loc}` : ''}`);
32
- console.log(error.message);
33
- });
34
- }
35
- else {
36
- utils_1.logger.event(`${prefix} Compiled in ${stats.endTime - stats.startTime} ms (${stats.compilation.modules.size} modules)`);
37
- }
38
- });
39
- }
40
- updateProgress(opts) {
41
- opts;
42
- }
43
- }
44
- exports.default = UmiProgressPlugin;
56
+ } else {
57
+ import_utils.logger.event(`${prefix} Compiled in ${stats.endTime - stats.startTime} ms (${stats.compilation.modules.size} modules)`);
58
+ }
59
+ });
60
+ }
61
+ updateProgress(opts) {
62
+ opts;
63
+ }
64
+ };
65
+ var ProgressPlugin_default = UmiProgressPlugin;
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {});
@@ -1,23 +1,42 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RuntimePublicPathPlugin = void 0;
4
- const PLUGIN_NAME = 'RuntimePublicPath';
5
- // ref: https://gist.github.com/ScriptedAlchemy/60d0c49ce049184f6ce3e86ca351fdca
6
- class RuntimePublicPathPlugin {
7
- apply(compiler) {
8
- compiler.hooks.make.tap(PLUGIN_NAME, (compilation) => {
9
- compilation.hooks.runtimeModule.tap(PLUGIN_NAME, (module) => {
10
- // The hook to get the public path ('__webpack_require__.p')
11
- // https://github.com/webpack/webpack/blob/master/lib/runtime/PublicPathRuntimeModule.js
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;
16
- // @ts-ignore
17
- module._cachedGeneratedCode = `__webpack_require__.p = (globalThis || window).publicPath || '/';`;
18
- }
19
- });
20
- });
21
- }
22
- }
23
- exports.RuntimePublicPathPlugin = RuntimePublicPathPlugin;
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
+ // RuntimePublicPathPlugin.ts
20
+ var RuntimePublicPathPlugin_exports = {};
21
+ __export(RuntimePublicPathPlugin_exports, {
22
+ RuntimePublicPathPlugin: () => RuntimePublicPathPlugin
23
+ });
24
+ module.exports = __toCommonJS(RuntimePublicPathPlugin_exports);
25
+ var PLUGIN_NAME = "RuntimePublicPath";
26
+ var RuntimePublicPathPlugin = class {
27
+ apply(compiler) {
28
+ compiler.hooks.make.tap(PLUGIN_NAME, (compilation) => {
29
+ compilation.hooks.runtimeModule.tap(PLUGIN_NAME, (module2) => {
30
+ if (module2.constructor.name === "PublicPathRuntimeModule") {
31
+ if (module2.getGeneratedCode().includes("webpack:///mini-css-extract-plugin"))
32
+ return;
33
+ module2._cachedGeneratedCode = `__webpack_require__.p = (typeof globalThis !== undefined ? globalThis : window).publicPath || '/';`;
34
+ }
35
+ });
36
+ });
37
+ }
38
+ };
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ RuntimePublicPathPlugin
42
+ });
@@ -1,14 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const PLUGIN_NAME = 'SamplePlugin';
4
- class _SamplePlugin {
5
- constructor(options = {}) {
6
- this.options = options;
7
- }
8
- apply(compiler) {
9
- compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
10
- compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_) => { });
11
- });
12
- }
13
- }
14
- exports.default = _SamplePlugin;
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
+ // _SamplePlugin.ts
20
+ var SamplePlugin_exports = {};
21
+ __export(SamplePlugin_exports, {
22
+ default: () => SamplePlugin_default
23
+ });
24
+ module.exports = __toCommonJS(SamplePlugin_exports);
25
+ var PLUGIN_NAME = "SamplePlugin";
26
+ var _SamplePlugin = class {
27
+ constructor(options = {}) {
28
+ this.options = options;
29
+ }
30
+ apply(compiler) {
31
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
32
+ compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_) => {
33
+ });
34
+ });
35
+ }
36
+ };
37
+ var SamplePlugin_default = _SamplePlugin;
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {});
@@ -1,31 +1,41 @@
1
- "use strict";
2
- // MIT: copy from https://github.com/vercel/next.js/blob/canary/packages/next/build/webpack/require-hook.ts
3
- // sync injects a hook for webpack and webpack/... requires to use the internal ncc webpack version
4
- // this is in order for userland plugins to attach to the same webpack instance as umi
5
- // the individual compiled modules are as defined for the compilation in bundles/webpack/packages/*
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- 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 __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
8
14
  };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- // @ts-ignore
11
- const deepImports_json_1 = __importDefault(require("@umijs/bundler-webpack/compiled/webpack/deepImports.json"));
12
- const hookPropertyMap = new Map([
13
- ['webpack', '@umijs/bundler-webpack/compiled/webpack'],
14
- ['webpack/package', '@umijs/bundler-webpack/compiled/webpack/package'],
15
- ['webpack/package.json', '@umijs/bundler-webpack/compiled/webpack/package'],
16
- ['webpack/lib/webpack', '@umijs/bundler-webpack/compiled/webpack'],
17
- ['webpack/lib/webpack.js', '@umijs/bundler-webpack/compiled/webpack'],
15
+ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target, mod2));
16
+
17
+ // requireHook.ts
18
+ var import_deepImports = __toESM(require("@umijs/bundler-webpack/compiled/webpack/deepImports.json"));
19
+ var import_path = require("path");
20
+ var PKG_ROOT = (0, import_path.join)(__dirname, "../");
21
+ var resolve = (p) => (0, import_path.join)(PKG_ROOT, p);
22
+ var hookPropertyMap = /* @__PURE__ */ new Map([
23
+ ["webpack", resolve("compiled/webpack")],
24
+ ["webpack/package", resolve("compiled/webpack/package")],
25
+ ["webpack/package.json", resolve("compiled/webpack/package")],
26
+ ["webpack/lib/webpack", resolve("compiled/webpack")],
27
+ ["webpack/lib/webpack.js", resolve("compiled/webpack")]
18
28
  ]);
19
- deepImports_json_1.default.forEach((item) => {
20
- const name = item.split('/').pop();
21
- hookPropertyMap.set(item, `@umijs/bundler-webpack/compiled/webpack/${name}`);
22
- hookPropertyMap.set(`${item}.js`, `@umijs/bundler-webpack/compiled/webpack/${name}`);
29
+ import_deepImports.default.forEach((item) => {
30
+ const name = item.split("/").pop();
31
+ hookPropertyMap.set(item, resolve(`compiled/webpack/${name}`));
32
+ hookPropertyMap.set(`${item}.js`, resolve(`compiled/webpack/${name}`));
23
33
  });
24
- const mod = require('module');
25
- const resolveFilename = mod._resolveFilename;
26
- mod._resolveFilename = function (request, parent, isMain, options) {
27
- const hookResolved = hookPropertyMap.get(request);
28
- if (hookResolved)
29
- request = hookResolved;
30
- return resolveFilename.call(mod, request, parent, isMain, options);
34
+ var mod = require("module");
35
+ var resolveFilename = mod._resolveFilename;
36
+ mod._resolveFilename = function(request, parent, isMain, options) {
37
+ const hookResolved = hookPropertyMap.get(request);
38
+ if (hookResolved)
39
+ request = hookResolved;
40
+ return resolveFilename.call(mod, request, parent, isMain, options);
31
41
  };