@umijs/bundler-webpack 4.2.6-alpha.6 → 4.2.6
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.
- package/dist/build.d.ts +22 -0
- package/dist/build.js +151 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +96 -0
- package/dist/config/_sampleFeature.d.ts +10 -0
- package/dist/config/_sampleFeature.js +35 -0
- package/dist/config/assetRules.d.ts +11 -0
- package/dist/config/assetRules.js +48 -0
- package/dist/config/bundleAnalyzerPlugin.d.ts +10 -0
- package/dist/config/bundleAnalyzerPlugin.js +43 -0
- package/dist/config/compressPlugin.d.ts +10 -0
- package/dist/config/compressPlugin.js +128 -0
- package/dist/config/config.d.ts +31 -0
- package/dist/config/config.js +243 -0
- package/dist/config/copyPlugin.d.ts +10 -0
- package/dist/config/copyPlugin.js +63 -0
- package/dist/config/cssRules.d.ts +11 -0
- package/dist/config/cssRules.js +165 -0
- package/dist/config/definePlugin.d.ts +15 -0
- package/dist/config/definePlugin.js +79 -0
- package/dist/config/detectCssModulesInDependence.d.ts +10 -0
- package/dist/config/detectCssModulesInDependence.js +151 -0
- package/dist/config/detectDeadCode.d.ts +12 -0
- package/dist/config/detectDeadCode.js +191 -0
- package/dist/config/detectDeadCodePlugin.d.ts +9 -0
- package/dist/config/detectDeadCodePlugin.js +82 -0
- package/dist/config/fastRefreshPlugin.d.ts +12 -0
- package/dist/config/fastRefreshPlugin.js +49 -0
- package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
- package/dist/config/forkTSCheckerPlugin.js +49 -0
- package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
- package/dist/config/harmonyLinkingErrorPlugin.js +53 -0
- package/dist/config/ignorePlugin.d.ts +10 -0
- package/dist/config/ignorePlugin.js +40 -0
- package/dist/config/javaScriptRules.d.ts +16 -0
- package/dist/config/javaScriptRules.js +191 -0
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +40 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +11 -0
- package/dist/config/miniCSSExtractPlugin.js +55 -0
- package/dist/config/nodePolyfill.d.ts +10 -0
- package/dist/config/nodePolyfill.js +51 -0
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +38 -0
- package/dist/config/progressPlugin.d.ts +11 -0
- package/dist/config/progressPlugin.js +53 -0
- package/dist/config/purgecssWebpackPlugin.d.ts +10 -0
- package/dist/config/purgecssWebpackPlugin.js +43 -0
- package/dist/config/speedMeasureWebpackPlugin.d.ts +6 -0
- package/dist/config/speedMeasureWebpackPlugin.js +59 -0
- package/dist/config/ssrPlugin.d.ts +11 -0
- package/dist/config/ssrPlugin.js +98 -0
- package/dist/config/svgRules.d.ts +12 -0
- package/dist/config/svgRules.js +70 -0
- package/dist/constants.d.ts +15 -0
- package/dist/constants.js +59 -0
- package/dist/dev.d.ts +40 -0
- package/dist/dev.js +208 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +32 -0
- package/dist/loader/svgr.d.ts +4 -0
- package/dist/loader/svgr.js +84 -0
- package/dist/loader/swc.d.ts +4 -0
- package/dist/loader/swc.js +149 -0
- package/dist/parcelCSS.d.ts +2 -0
- package/dist/parcelCSS.js +39 -0
- package/dist/plugins/EsbuildMinifyFix.d.ts +8 -0
- package/dist/plugins/EsbuildMinifyFix.js +136 -0
- package/dist/plugins/ProgressPlugin.d.ts +15 -0
- package/dist/plugins/ProgressPlugin.js +69 -0
- package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
- package/dist/plugins/RuntimePublicPathPlugin.js +45 -0
- package/dist/plugins/_SamplePlugin.d.ts +9 -0
- package/dist/plugins/_SamplePlugin.js +37 -0
- package/dist/requireHook.d.ts +1 -0
- package/dist/requireHook.js +49 -0
- package/dist/schema.d.ts +4 -0
- package/dist/schema.js +178 -0
- package/dist/server/server.d.ts +17 -0
- package/dist/server/server.js +223 -0
- package/dist/server/ws.d.ts +13 -0
- package/dist/server/ws.js +76 -0
- package/dist/swcPlugins/autoCSSModules.d.ts +17 -0
- package/dist/swcPlugins/autoCSSModules.js +63 -0
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +32 -0
- package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
- package/dist/swcPlugins/lockCoreJS.js +56 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.js +61 -0
- package/dist/utils/browsersList.d.ts +5 -0
- package/dist/utils/browsersList.js +33 -0
- package/dist/utils/depMatch.d.ts +6 -0
- package/dist/utils/depMatch.js +72 -0
- package/dist/utils/formatWebpackMessages.d.ts +12 -0
- package/dist/utils/formatWebpackMessages.js +128 -0
- package/dist/utils/getEsBuildTarget.d.ts +7 -0
- package/dist/utils/getEsBuildTarget.js +46 -0
- package/dist/utils/pkgUpContainsName.d.ts +1 -0
- package/dist/utils/pkgUpContainsName.js +50 -0
- package/package.json +5 -5
|
@@ -0,0 +1,149 @@
|
|
|
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(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/loader/swc.ts
|
|
30
|
+
var swc_exports = {};
|
|
31
|
+
__export(swc_exports, {
|
|
32
|
+
default: () => swc_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(swc_exports);
|
|
35
|
+
var import_core = require("@swc/core");
|
|
36
|
+
var import_types = require("../types");
|
|
37
|
+
var import_utils = require("@umijs/utils");
|
|
38
|
+
function getBaseOpts({ filename }) {
|
|
39
|
+
const isTSFile = filename.endsWith(".ts");
|
|
40
|
+
const isTypeScript = isTSFile || filename.endsWith(".tsx");
|
|
41
|
+
const isDev = process.env.NODE_ENV === import_types.Env.development;
|
|
42
|
+
const swcOpts = {
|
|
43
|
+
module: {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
type: "es6",
|
|
46
|
+
ignoreDynamic: true
|
|
47
|
+
},
|
|
48
|
+
jsc: {
|
|
49
|
+
parser: {
|
|
50
|
+
syntax: isTypeScript ? "typescript" : "ecmascript",
|
|
51
|
+
[isTypeScript ? "tsx" : "jsx"]: !isTSFile,
|
|
52
|
+
dynamicImport: isTypeScript
|
|
53
|
+
},
|
|
54
|
+
target: "es2015",
|
|
55
|
+
transform: {
|
|
56
|
+
react: {
|
|
57
|
+
runtime: "automatic",
|
|
58
|
+
pragma: "React.createElement",
|
|
59
|
+
pragmaFrag: "React.Fragment",
|
|
60
|
+
throwIfNamespace: true,
|
|
61
|
+
development: isDev,
|
|
62
|
+
useBuiltins: true
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return swcOpts;
|
|
68
|
+
}
|
|
69
|
+
function swcLoader(contents, inputSourceMap) {
|
|
70
|
+
const callback = this.async();
|
|
71
|
+
const loaderOpts = this.getOptions();
|
|
72
|
+
if (inputSourceMap && typeof inputSourceMap === "object") {
|
|
73
|
+
inputSourceMap = JSON.stringify(inputSourceMap);
|
|
74
|
+
}
|
|
75
|
+
const {
|
|
76
|
+
sync = false,
|
|
77
|
+
parseMap = false,
|
|
78
|
+
excludeFiles = [],
|
|
79
|
+
enableAutoCssModulesPlugin = false,
|
|
80
|
+
mergeConfigs,
|
|
81
|
+
...otherOpts
|
|
82
|
+
} = loaderOpts;
|
|
83
|
+
const filename = this.resourcePath;
|
|
84
|
+
const isSkip = excludeFiles.some((pattern) => {
|
|
85
|
+
if (typeof pattern === "string") {
|
|
86
|
+
return filename == pattern;
|
|
87
|
+
}
|
|
88
|
+
return pattern.test(filename);
|
|
89
|
+
});
|
|
90
|
+
if (isSkip) {
|
|
91
|
+
return callback(
|
|
92
|
+
null,
|
|
93
|
+
contents,
|
|
94
|
+
parseMap ? JSON.parse(inputSourceMap) : inputSourceMap
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
let swcOpts = {
|
|
98
|
+
...getBaseOpts({
|
|
99
|
+
filename
|
|
100
|
+
}),
|
|
101
|
+
// filename
|
|
102
|
+
filename,
|
|
103
|
+
sourceFileName: filename,
|
|
104
|
+
// source map
|
|
105
|
+
sourceMaps: this.sourceMap,
|
|
106
|
+
...inputSourceMap ? {
|
|
107
|
+
inputSourceMap
|
|
108
|
+
} : {},
|
|
109
|
+
...otherOpts
|
|
110
|
+
};
|
|
111
|
+
if (enableAutoCssModulesPlugin) {
|
|
112
|
+
swcOpts = (0, import_utils.deepmerge)(swcOpts, {
|
|
113
|
+
jsc: {
|
|
114
|
+
experimental: {
|
|
115
|
+
plugins: [[require.resolve("swc-plugin-auto-css-modules"), {}]]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (mergeConfigs) {
|
|
121
|
+
swcOpts = (0, import_utils.deepmerge)(swcOpts, mergeConfigs);
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
if (sync) {
|
|
125
|
+
const output = (0, import_core.transformSync)(contents, swcOpts);
|
|
126
|
+
callback(
|
|
127
|
+
null,
|
|
128
|
+
output.code,
|
|
129
|
+
parseMap ? JSON.parse(output.map) : output.map
|
|
130
|
+
);
|
|
131
|
+
} else {
|
|
132
|
+
(0, import_core.transform)(contents, swcOpts).then(
|
|
133
|
+
(output) => {
|
|
134
|
+
callback(
|
|
135
|
+
null,
|
|
136
|
+
output.code,
|
|
137
|
+
parseMap ? JSON.parse(output.map) : output.map
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
(err) => {
|
|
141
|
+
callback(err);
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
} catch (e) {
|
|
146
|
+
callback(e);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
var swc_default = swcLoader;
|
|
@@ -0,0 +1,39 @@
|
|
|
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(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/parcelCSS.ts
|
|
30
|
+
var parcelCSS_exports = {};
|
|
31
|
+
__export(parcelCSS_exports, {
|
|
32
|
+
parcelCSS: () => parcelCSS
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(parcelCSS_exports);
|
|
35
|
+
var parcelCSS = __toESM(require("lightningcss"));
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
parcelCSS
|
|
39
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Compilation, Compiler, sources } from '../../compiled/webpack';
|
|
2
|
+
export declare class EsbuildMinifyFix {
|
|
3
|
+
private name;
|
|
4
|
+
constructor();
|
|
5
|
+
apply(compiler: Compiler): void;
|
|
6
|
+
private isIIFE;
|
|
7
|
+
minifyFix(compilation: Compilation, assets: Record<string, sources.Source>): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
// src/plugins/EsbuildMinifyFix.ts
|
|
20
|
+
var EsbuildMinifyFix_exports = {};
|
|
21
|
+
__export(EsbuildMinifyFix_exports, {
|
|
22
|
+
EsbuildMinifyFix: () => EsbuildMinifyFix
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(EsbuildMinifyFix_exports);
|
|
25
|
+
var import_utils = require("@umijs/utils");
|
|
26
|
+
var import_webpack = require("../../compiled/webpack");
|
|
27
|
+
var JS_FILE_REG = /\.(js|mjs|cjs)$/;
|
|
28
|
+
var EsbuildMinifyFix = class {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.name = `EsbuildMinifyFix`;
|
|
31
|
+
}
|
|
32
|
+
apply(compiler) {
|
|
33
|
+
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
34
|
+
compilation.hooks.processAssets.tapPromise(
|
|
35
|
+
{
|
|
36
|
+
name: this.name,
|
|
37
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING,
|
|
38
|
+
additionalAssets: true
|
|
39
|
+
},
|
|
40
|
+
(assets) => this.minifyFix(compilation, assets)
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
isIIFE(source) {
|
|
45
|
+
source = source.trim();
|
|
46
|
+
if (source.startsWith('(function(){"use strict";')) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (source.startsWith("(function(){") && (source.endsWith("})()") || source.endsWith("})();"))) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
async minifyFix(compilation, assets) {
|
|
55
|
+
const matchObject = import_webpack.ModuleFilenameHelpers.matchObject.bind(void 0, {
|
|
56
|
+
include: [JS_FILE_REG]
|
|
57
|
+
});
|
|
58
|
+
const assetsForMinify = await Promise.all(
|
|
59
|
+
Object.keys(assets).filter((name) => {
|
|
60
|
+
var _a;
|
|
61
|
+
if (!matchObject(name)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const { info } = compilation.getAsset(name) || {};
|
|
65
|
+
if (!(info == null ? void 0 : info.minimized)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (info == null ? void 0 : info.copied) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (info == null ? void 0 : info.EsbuildMinifyFix) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (name.endsWith(".worker.js")) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if ((_a = info == null ? void 0 : info.related) == null ? void 0 : _a.sourceMap) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}).map(async (name) => {
|
|
82
|
+
const { info, source } = compilation.getAsset(name);
|
|
83
|
+
return { name, info, inputSource: source };
|
|
84
|
+
})
|
|
85
|
+
);
|
|
86
|
+
if (assetsForMinify.length === 0) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const { SourceMapSource, RawSource } = import_webpack.sources;
|
|
90
|
+
for (const asset of assetsForMinify) {
|
|
91
|
+
const { name, inputSource } = asset;
|
|
92
|
+
const { source, map } = inputSource.sourceAndMap();
|
|
93
|
+
const originCode = source.toString();
|
|
94
|
+
let newCode = originCode;
|
|
95
|
+
if (!newCode.startsWith('"use strict";(self.') && !newCode.startsWith("(self.webpack") && !this.isIIFE(newCode)) {
|
|
96
|
+
const bundle = new import_utils.MagicString(newCode);
|
|
97
|
+
bundle.prepend("!(function(){").append("}());");
|
|
98
|
+
newCode = bundle.toString();
|
|
99
|
+
const output = {};
|
|
100
|
+
if (map) {
|
|
101
|
+
const bundleMap = bundle.generateMap({
|
|
102
|
+
source: name,
|
|
103
|
+
file: `${name}.map`,
|
|
104
|
+
includeContent: true,
|
|
105
|
+
hires: true
|
|
106
|
+
});
|
|
107
|
+
const originMapAsString = JSON.stringify(map);
|
|
108
|
+
const mergedMap = (0, import_utils.remapping)(JSON.stringify(bundleMap), (file) => {
|
|
109
|
+
if (file === name) {
|
|
110
|
+
return originMapAsString;
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
});
|
|
114
|
+
output.source = new SourceMapSource(
|
|
115
|
+
newCode,
|
|
116
|
+
name,
|
|
117
|
+
mergedMap,
|
|
118
|
+
originCode,
|
|
119
|
+
map,
|
|
120
|
+
true
|
|
121
|
+
);
|
|
122
|
+
} else {
|
|
123
|
+
output.source = new RawSource(newCode);
|
|
124
|
+
}
|
|
125
|
+
compilation.updateAsset(name, output.source, {
|
|
126
|
+
...asset.info,
|
|
127
|
+
EsbuildMinifyFix: true
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {
|
|
135
|
+
EsbuildMinifyFix
|
|
136
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Compiler, ProgressPlugin } from '@umijs/bundler-webpack/compiled/webpack';
|
|
2
|
+
interface IOpts {
|
|
3
|
+
name?: string;
|
|
4
|
+
}
|
|
5
|
+
declare class UmiProgressPlugin extends ProgressPlugin {
|
|
6
|
+
options: IOpts;
|
|
7
|
+
constructor(options?: IOpts);
|
|
8
|
+
apply(compiler: Compiler): void;
|
|
9
|
+
updateProgress(opts: {
|
|
10
|
+
percent: number;
|
|
11
|
+
message: string;
|
|
12
|
+
details: any[];
|
|
13
|
+
}): void;
|
|
14
|
+
}
|
|
15
|
+
export default UmiProgressPlugin;
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
// src/plugins/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(
|
|
54
|
+
`${error.moduleName}${error.loc ? `:${error.loc}` : ""}`
|
|
55
|
+
);
|
|
56
|
+
console.log(error.message);
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
import_utils.logger.event(
|
|
60
|
+
`${prefix} Compiled in ${stats.endTime - stats.startTime} ms (${stats.compilation.modules.size} modules)`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
updateProgress(opts) {
|
|
66
|
+
opts;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var ProgressPlugin_default = UmiProgressPlugin;
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
// src/plugins/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(
|
|
30
|
+
PLUGIN_NAME,
|
|
31
|
+
(module2) => {
|
|
32
|
+
if (module2.constructor.name === "PublicPathRuntimeModule") {
|
|
33
|
+
if (module2.getGeneratedCode().includes("webpack:///mini-css-extract-plugin"))
|
|
34
|
+
return;
|
|
35
|
+
module2._cachedGeneratedCode = `__webpack_require__.p = (typeof globalThis !== 'undefined' ? globalThis : window).publicPath || '/';`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
RuntimePublicPathPlugin
|
|
45
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
// src/plugins/_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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
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;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
|
|
21
|
+
mod2
|
|
22
|
+
));
|
|
23
|
+
|
|
24
|
+
// src/requireHook.ts
|
|
25
|
+
var import_deepImports = __toESM(require("@umijs/bundler-webpack/compiled/webpack/deepImports.json"));
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
var PKG_ROOT = (0, import_path.join)(__dirname, "../");
|
|
28
|
+
var resolve = (p) => (0, import_path.join)(PKG_ROOT, p);
|
|
29
|
+
var hookPropertyMap = /* @__PURE__ */ new Map([
|
|
30
|
+
["webpack", resolve("compiled/webpack")],
|
|
31
|
+
["webpack/package", resolve("compiled/webpack/package")],
|
|
32
|
+
["webpack/package.json", resolve("compiled/webpack/package")],
|
|
33
|
+
["webpack/lib/webpack", resolve("compiled/webpack")],
|
|
34
|
+
["webpack/lib/webpack.js", resolve("compiled/webpack")],
|
|
35
|
+
["tapable", require.resolve("@umijs/bundler-utils/compiled/tapable")]
|
|
36
|
+
]);
|
|
37
|
+
import_deepImports.default.forEach((item) => {
|
|
38
|
+
const name = item.split("/").pop();
|
|
39
|
+
hookPropertyMap.set(item, resolve(`compiled/webpack/${name}`));
|
|
40
|
+
hookPropertyMap.set(`${item}.js`, resolve(`compiled/webpack/${name}`));
|
|
41
|
+
});
|
|
42
|
+
var mod = require("module");
|
|
43
|
+
var resolveFilename = mod._resolveFilename;
|
|
44
|
+
mod._resolveFilename = function(request, parent, isMain, options) {
|
|
45
|
+
const hookResolved = hookPropertyMap.get(request);
|
|
46
|
+
if (hookResolved)
|
|
47
|
+
request = hookResolved;
|
|
48
|
+
return resolveFilename.call(mod, request, parent, isMain, options);
|
|
49
|
+
};
|
package/dist/schema.d.ts
ADDED