@umijs/bundler-webpack 4.0.41 → 4.0.43
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/client/utils/formatWebpackMessages.js +27 -8
- package/compiled/autoprefixer/browserslist/index.d.ts +21 -1
- package/compiled/autoprefixer/index.js +2 -2
- package/compiled/autoprefixer/package.json +1 -1
- package/compiled/autoprefixer/postcss/lib/processor.d.ts +1 -1
- package/compiled/babel-loader/index.js +8 -2
- package/compiled/babel-loader/package.json +1 -1
- package/compiled/less-loader/index.js +1 -1
- package/compiled/less-loader/package.json +1 -1
- package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +22 -60
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +2 -10
- package/compiled/mini-css-extract-plugin/index.js +492 -696
- package/compiled/mini-css-extract-plugin/loader.js +54 -120
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +27 -44
- package/compiled/postcss-loader/index.js +1 -1
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/sass-loader/package.json +1 -1
- package/compiled/sass-loader/sass.default.dart.js +4 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +90 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
- package/compiled/terser/@jridgewell/source-map/dist/types/source-map.d.ts +25 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser/index.js +1 -1
- package/compiled/terser/package.json +1 -1
- package/compiled/terser/tools/terser.d.ts +6 -3
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser-webpack-plugin/index.js +1211 -3390
- package/compiled/terser-webpack-plugin/package.json +1 -1
- package/compiled/terser-webpack-plugin/types/index.d.ts +10 -10
- package/compiled/terser-webpack-plugin/types/utils.d.ts +10 -9
- package/compiled/terser-webpack-plugin/utils.js +36 -10
- package/compiled/webpack/package.json +1 -1
- package/compiled/webpack/types.d.ts +137 -126
- package/compiled/webpack-5-chain/index.js +1 -1
- package/compiled/webpack-5-chain/package.json +1 -1
- package/compiled/webpack-5-chain/types/index.d.ts +76 -20
- package/compiled/webpack-bundle-analyzer/index.js +7 -6
- package/compiled/webpack-bundle-analyzer/package.json +1 -1
- package/compiled/webpack-bundle-analyzer/public/viewer.js +2 -2
- package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -1
- package/compiled/webpack-dev-middleware/index.js +5 -5
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/webpackbar/LICENSE +20 -0
- package/compiled/webpackbar/dist/index.d.ts +121 -0
- package/compiled/webpackbar/index.js +7 -0
- package/compiled/webpackbar/package.json +1 -0
- package/compiled/ws/LICENSE +13 -12
- package/compiled/ws/index.d.ts +73 -33
- package/compiled/ws/index.js +1 -1
- package/compiled/ws/package.json +1 -1
- package/dist/build.js +8 -2
- package/dist/cli.js +4 -1
- package/dist/config/compressPlugin.js +4 -1
- package/dist/config/config.js +41 -11
- package/dist/config/cssRules.js +17 -5
- package/dist/config/detectDeadCode.js +38 -8
- package/dist/config/detectDeadCodePlugin.js +8 -2
- package/dist/config/fastRefreshPlugin.js +4 -1
- package/dist/config/forkTSCheckerPlugin.js +4 -1
- package/dist/config/harmonyLinkingErrorPlugin.js +14 -11
- package/dist/config/javaScriptRules.js +21 -9
- package/dist/config/miniCSSExtractPlugin.js +4 -1
- package/dist/config/progressPlugin.js +16 -7
- package/dist/config/speedMeasureWebpackPlugin.js +7 -2
- package/dist/config/ssrPlugin.js +20 -6
- package/dist/config/svgRules.js +4 -1
- package/dist/dev.js +29 -13
- package/dist/loader/svgr.js +16 -11
- package/dist/loader/swc.d.ts +2 -2
- package/dist/loader/swc.js +66 -10
- package/dist/parcelCSS.js +4 -1
- package/dist/plugins/ProgressPlugin.js +6 -2
- package/dist/plugins/RuntimePublicPathPlugin.js +9 -6
- package/dist/plugins/_SamplePlugin.d.ts +1 -1
- package/dist/plugins/_SamplePlugin.js +1 -1
- package/dist/requireHook.js +4 -1
- package/dist/schema.js +62 -23
- package/dist/server/server.d.ts +1 -4
- package/dist/server/server.js +37 -23
- package/dist/server/ws.js +8 -3
- package/dist/swcPlugins/autoCSSModules.d.ts +5 -1
- package/dist/swcPlugins/autoCSSModules.js +4 -1
- package/dist/swcPlugins/lockCoreJS.js +8 -2
- package/dist/types.d.ts +15 -3
- package/dist/utils/formatWebpackMessages.js +31 -9
- package/dist/utils/getEsBuildTarget.js +7 -1
- package/package.json +30 -26
package/dist/loader/swc.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
17
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
24
|
|
|
19
25
|
// src/loader/swc.ts
|
|
@@ -24,6 +30,7 @@ __export(swc_exports, {
|
|
|
24
30
|
module.exports = __toCommonJS(swc_exports);
|
|
25
31
|
var import_core = require("@swc/core");
|
|
26
32
|
var import_types = require("../types");
|
|
33
|
+
var import_utils = require("@umijs/utils");
|
|
27
34
|
function getBaseOpts({ filename }) {
|
|
28
35
|
const isTSFile = filename.endsWith(".ts");
|
|
29
36
|
const isTypeScript = isTSFile || filename.endsWith(".tsx");
|
|
@@ -54,30 +61,79 @@ function getBaseOpts({ filename }) {
|
|
|
54
61
|
};
|
|
55
62
|
return swcOpts;
|
|
56
63
|
}
|
|
57
|
-
function swcLoader(contents) {
|
|
64
|
+
function swcLoader(contents, inputSourceMap) {
|
|
58
65
|
const callback = this.async();
|
|
59
66
|
const loaderOpts = this.getOptions();
|
|
60
|
-
|
|
67
|
+
if (inputSourceMap && typeof inputSourceMap === "object") {
|
|
68
|
+
inputSourceMap = JSON.stringify(inputSourceMap);
|
|
69
|
+
}
|
|
70
|
+
const {
|
|
71
|
+
sync = false,
|
|
72
|
+
parseMap = false,
|
|
73
|
+
excludeFiles = [],
|
|
74
|
+
enableAutoCssModulesPlugin = false,
|
|
75
|
+
mergeConfigs,
|
|
76
|
+
...otherOpts
|
|
77
|
+
} = loaderOpts;
|
|
61
78
|
const filename = this.resourcePath;
|
|
62
|
-
const
|
|
79
|
+
const isSkip = excludeFiles.some((pattern) => {
|
|
80
|
+
if (typeof pattern === "string") {
|
|
81
|
+
return filename == pattern;
|
|
82
|
+
}
|
|
83
|
+
return pattern.test(filename);
|
|
84
|
+
});
|
|
85
|
+
if (isSkip) {
|
|
86
|
+
return callback(
|
|
87
|
+
null,
|
|
88
|
+
contents,
|
|
89
|
+
parseMap ? JSON.parse(inputSourceMap) : inputSourceMap
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
let swcOpts = {
|
|
63
93
|
...getBaseOpts({
|
|
64
94
|
filename
|
|
65
95
|
}),
|
|
66
96
|
filename,
|
|
67
|
-
sourceMaps: this.sourceMap,
|
|
68
97
|
sourceFileName: filename,
|
|
98
|
+
sourceMaps: this.sourceMap,
|
|
99
|
+
...inputSourceMap ? {
|
|
100
|
+
inputSourceMap
|
|
101
|
+
} : {},
|
|
69
102
|
...otherOpts
|
|
70
103
|
};
|
|
104
|
+
if (enableAutoCssModulesPlugin) {
|
|
105
|
+
swcOpts = (0, import_utils.deepmerge)(swcOpts, {
|
|
106
|
+
jsc: {
|
|
107
|
+
experimental: {
|
|
108
|
+
plugins: [[require.resolve("swc-plugin-auto-css-modules"), {}]]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (mergeConfigs) {
|
|
114
|
+
swcOpts = (0, import_utils.deepmerge)(swcOpts, mergeConfigs);
|
|
115
|
+
}
|
|
71
116
|
try {
|
|
72
117
|
if (sync) {
|
|
73
118
|
const output = (0, import_core.transformSync)(contents, swcOpts);
|
|
74
|
-
callback(
|
|
119
|
+
callback(
|
|
120
|
+
null,
|
|
121
|
+
output.code,
|
|
122
|
+
parseMap ? JSON.parse(output.map) : output.map
|
|
123
|
+
);
|
|
75
124
|
} else {
|
|
76
|
-
(0, import_core.transform)(contents, swcOpts).then(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
125
|
+
(0, import_core.transform)(contents, swcOpts).then(
|
|
126
|
+
(output) => {
|
|
127
|
+
callback(
|
|
128
|
+
null,
|
|
129
|
+
output.code,
|
|
130
|
+
parseMap ? JSON.parse(output.map) : output.map
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
(err) => {
|
|
134
|
+
callback(err);
|
|
135
|
+
}
|
|
136
|
+
);
|
|
81
137
|
}
|
|
82
138
|
} catch (e) {
|
|
83
139
|
callback(e);
|
package/dist/parcelCSS.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/parcelCSS.ts
|
|
@@ -50,11 +50,15 @@ var UmiProgressPlugin = class extends import_webpack.ProgressPlugin {
|
|
|
50
50
|
hasWarnings;
|
|
51
51
|
if (hasErrors) {
|
|
52
52
|
errors.forEach((error) => {
|
|
53
|
-
import_utils.logger.error(
|
|
53
|
+
import_utils.logger.error(
|
|
54
|
+
`${error.moduleName}${error.loc ? `:${error.loc}` : ""}`
|
|
55
|
+
);
|
|
54
56
|
console.log(error.message);
|
|
55
57
|
});
|
|
56
58
|
} else {
|
|
57
|
-
import_utils.logger.event(
|
|
59
|
+
import_utils.logger.event(
|
|
60
|
+
`${prefix} Compiled in ${stats.endTime - stats.startTime} ms (${stats.compilation.modules.size} modules)`
|
|
61
|
+
);
|
|
58
62
|
}
|
|
59
63
|
});
|
|
60
64
|
}
|
|
@@ -26,13 +26,16 @@ var PLUGIN_NAME = "RuntimePublicPath";
|
|
|
26
26
|
var RuntimePublicPathPlugin = class {
|
|
27
27
|
apply(compiler) {
|
|
28
28
|
compiler.hooks.make.tap(PLUGIN_NAME, (compilation) => {
|
|
29
|
-
compilation.hooks.runtimeModule.tap(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
}
|
|
34
37
|
}
|
|
35
|
-
|
|
38
|
+
);
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
};
|
package/dist/requireHook.js
CHANGED
|
@@ -12,7 +12,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
}
|
|
13
13
|
return to;
|
|
14
14
|
};
|
|
15
|
-
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
15
|
+
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
16
|
+
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
|
|
17
|
+
mod2
|
|
18
|
+
));
|
|
16
19
|
|
|
17
20
|
// src/requireHook.ts
|
|
18
21
|
var import_deepImports = __toESM(require("@umijs/bundler-webpack/compiled/webpack/deepImports.json"));
|
package/dist/schema.js
CHANGED
|
@@ -50,7 +50,9 @@ var options = [
|
|
|
50
50
|
"nosources-cheap-source-map",
|
|
51
51
|
"nosources-cheap-module-source-map"
|
|
52
52
|
];
|
|
53
|
-
var DEVTOOL_REGEX = new RegExp(
|
|
53
|
+
var DEVTOOL_REGEX = new RegExp(
|
|
54
|
+
`^(#@|@|#)?(${options.join("$|")})`
|
|
55
|
+
);
|
|
54
56
|
function getSchemas() {
|
|
55
57
|
return {
|
|
56
58
|
alias: (Joi) => Joi.object(),
|
|
@@ -59,21 +61,38 @@ function getSchemas() {
|
|
|
59
61
|
babelLoaderCustomize: (Joi) => Joi.string(),
|
|
60
62
|
cacheDirectoryPath: (Joi) => Joi.string(),
|
|
61
63
|
chainWebpack: (Joi) => Joi.function(),
|
|
62
|
-
copy: (Joi) => Joi.array().items(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
copy: (Joi) => Joi.array().items(
|
|
65
|
+
Joi.alternatives().try(
|
|
66
|
+
Joi.object({
|
|
67
|
+
from: Joi.string(),
|
|
68
|
+
to: Joi.string()
|
|
69
|
+
}),
|
|
70
|
+
Joi.string()
|
|
71
|
+
)
|
|
72
|
+
),
|
|
66
73
|
cssLoader: (Joi) => Joi.object(),
|
|
67
74
|
cssLoaderModules: (Joi) => Joi.object(),
|
|
68
|
-
cssMinifier: (Joi) => Joi.string().valid(
|
|
75
|
+
cssMinifier: (Joi) => Joi.string().valid(
|
|
76
|
+
import_types.CSSMinifier.cssnano,
|
|
77
|
+
import_types.CSSMinifier.esbuild,
|
|
78
|
+
import_types.CSSMinifier.parcelCSS,
|
|
79
|
+
import_types.CSSMinifier.none
|
|
80
|
+
),
|
|
69
81
|
cssMinifierOptions: (Joi) => Joi.object(),
|
|
70
82
|
deadCode: (Joi) => Joi.object(),
|
|
71
83
|
define: (Joi) => Joi.object(),
|
|
72
|
-
depTranspiler: (Joi) => Joi.string().valid(
|
|
84
|
+
depTranspiler: (Joi) => Joi.string().valid(
|
|
85
|
+
import_types.Transpiler.babel,
|
|
86
|
+
import_types.Transpiler.esbuild,
|
|
87
|
+
import_types.Transpiler.swc,
|
|
88
|
+
import_types.Transpiler.none
|
|
89
|
+
),
|
|
73
90
|
devtool: (Joi) => Joi.alternatives().try(Joi.string().regex(DEVTOOL_REGEX), Joi.boolean()),
|
|
74
91
|
esm: (Joi) => Joi.object(),
|
|
75
92
|
externals: (Joi) => Joi.alternatives().try(Joi.object(), Joi.string(), Joi.func()),
|
|
76
|
-
extraBabelIncludes: (Joi) => Joi.array().items(
|
|
93
|
+
extraBabelIncludes: (Joi) => Joi.array().items(
|
|
94
|
+
Joi.alternatives().try(Joi.string(), Joi.object().instance(RegExp))
|
|
95
|
+
),
|
|
77
96
|
extraBabelPlugins: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.array())),
|
|
78
97
|
extraBabelPresets: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.array())),
|
|
79
98
|
extraPostCSSPlugins: (Joi) => Joi.array(),
|
|
@@ -83,7 +102,13 @@ function getSchemas() {
|
|
|
83
102
|
https: (Joi) => Joi.object(),
|
|
84
103
|
ignoreMomentLocale: (Joi) => Joi.boolean(),
|
|
85
104
|
inlineLimit: (Joi) => Joi.number(),
|
|
86
|
-
jsMinifier: (Joi) => Joi.string().valid(
|
|
105
|
+
jsMinifier: (Joi) => Joi.string().valid(
|
|
106
|
+
import_types.JSMinifier.esbuild,
|
|
107
|
+
import_types.JSMinifier.swc,
|
|
108
|
+
import_types.JSMinifier.terser,
|
|
109
|
+
import_types.JSMinifier.uglifyJs,
|
|
110
|
+
import_types.JSMinifier.none
|
|
111
|
+
),
|
|
87
112
|
jsMinifierOptions: (Joi) => Joi.object(),
|
|
88
113
|
lessLoader: (Joi) => Joi.object(),
|
|
89
114
|
manifest: (Joi) => Joi.object(),
|
|
@@ -91,19 +116,24 @@ function getSchemas() {
|
|
|
91
116
|
loader: Joi.string(),
|
|
92
117
|
loaderOptions: Joi.object()
|
|
93
118
|
}),
|
|
94
|
-
mfsu: (Joi) => Joi.alternatives(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
119
|
+
mfsu: (Joi) => Joi.alternatives(
|
|
120
|
+
Joi.object({
|
|
121
|
+
cacheDirectory: Joi.string(),
|
|
122
|
+
chainWebpack: Joi.function(),
|
|
123
|
+
esbuild: Joi.boolean(),
|
|
124
|
+
exclude: Joi.array().items(
|
|
125
|
+
Joi.alternatives().try(Joi.string(), Joi.object().regex())
|
|
126
|
+
),
|
|
127
|
+
include: Joi.array().items(Joi.string()),
|
|
128
|
+
mfName: Joi.string(),
|
|
129
|
+
remoteAliases: Joi.array().items(Joi.string()),
|
|
130
|
+
remoteName: Joi.string(),
|
|
131
|
+
runtimePublicPath: Joi.boolean(),
|
|
132
|
+
shared: Joi.object(),
|
|
133
|
+
strategy: Joi.string().valid("eager", "normal").default("normal")
|
|
134
|
+
}),
|
|
135
|
+
Joi.boolean()
|
|
136
|
+
),
|
|
107
137
|
outputPath: (Joi) => Joi.string(),
|
|
108
138
|
postcssLoader: (Joi) => Joi.object(),
|
|
109
139
|
proxy: (Joi) => Joi.alternatives().try(Joi.object(), Joi.array()),
|
|
@@ -111,7 +141,16 @@ function getSchemas() {
|
|
|
111
141
|
purgeCSS: (Joi) => Joi.object(),
|
|
112
142
|
runtimePublicPath: (Joi) => Joi.object(),
|
|
113
143
|
sassLoader: (Joi) => Joi.object(),
|
|
114
|
-
srcTranspiler: (Joi) => Joi.string().valid(
|
|
144
|
+
srcTranspiler: (Joi) => Joi.string().valid(
|
|
145
|
+
import_types.Transpiler.babel,
|
|
146
|
+
import_types.Transpiler.esbuild,
|
|
147
|
+
import_types.Transpiler.swc,
|
|
148
|
+
import_types.Transpiler.none
|
|
149
|
+
),
|
|
150
|
+
srcTranspilerOptions: (Joi) => Joi.object({
|
|
151
|
+
esbuild: Joi.object(),
|
|
152
|
+
swc: Joi.object()
|
|
153
|
+
}),
|
|
115
154
|
styleLoader: (Joi) => Joi.object(),
|
|
116
155
|
svgo: (Joi) => Joi.alternatives().try(Joi.object(), Joi.boolean()),
|
|
117
156
|
svgr: (Joi) => Joi.object(),
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { Configuration } from '@umijs/bundler-webpack/compiled/webpack';
|
|
4
|
-
import http from 'http';
|
|
5
2
|
import { IConfig } from '../types';
|
|
6
3
|
interface IOpts {
|
|
7
4
|
cwd: string;
|
|
@@ -16,5 +13,5 @@ interface IOpts {
|
|
|
16
13
|
onProgress?: Function;
|
|
17
14
|
onBeforeMiddleware?: Function;
|
|
18
15
|
}
|
|
19
|
-
export declare function createServer(opts: IOpts): Promise<
|
|
16
|
+
export declare function createServer(opts: IOpts): Promise<any>;
|
|
20
17
|
export {};
|
package/dist/server/server.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/server/server.ts
|
|
@@ -40,18 +43,23 @@ async function createServer(opts) {
|
|
|
40
43
|
const { proxy } = userConfig;
|
|
41
44
|
const app = (0, import_express.default)();
|
|
42
45
|
let ws;
|
|
43
|
-
app.use(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
app.use(
|
|
47
|
+
(0, import_cors.default)({
|
|
48
|
+
origin: true,
|
|
49
|
+
methods: ["GET", "HEAD", "PUT", "POST", "PATCH", "DELETE", "OPTIONS"],
|
|
50
|
+
credentials: true
|
|
51
|
+
})
|
|
52
|
+
);
|
|
48
53
|
app.use(require("@umijs/bundler-webpack/compiled/compression")());
|
|
49
54
|
app.use((req, res, next) => {
|
|
50
55
|
const file = req.path;
|
|
51
56
|
const filePath = (0, import_path.join)(opts.cwd, file);
|
|
52
57
|
const ext = (0, import_path.extname)(filePath);
|
|
53
58
|
if (ext === ".js" && (0, import_fs.existsSync)(filePath)) {
|
|
54
|
-
import_utils.logger.info(
|
|
59
|
+
import_utils.logger.info(
|
|
60
|
+
"[dev]",
|
|
61
|
+
`${file} is responded with ${filePath}, remove it to use original file`
|
|
62
|
+
);
|
|
55
63
|
res.sendFile(filePath);
|
|
56
64
|
} else {
|
|
57
65
|
next();
|
|
@@ -71,12 +79,14 @@ async function createServer(opts) {
|
|
|
71
79
|
details: []
|
|
72
80
|
};
|
|
73
81
|
progresses.push(progress);
|
|
74
|
-
config.plugins.push(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
config.plugins.push(
|
|
83
|
+
new import_webpack.default.ProgressPlugin((percent, msg, ...details) => {
|
|
84
|
+
progress.percent = percent;
|
|
85
|
+
progress.status = msg;
|
|
86
|
+
progress.details = details;
|
|
87
|
+
opts.onProgress({ progresses });
|
|
88
|
+
})
|
|
89
|
+
);
|
|
80
90
|
});
|
|
81
91
|
}
|
|
82
92
|
const compiler = (0, import_webpack.default)(configs);
|
|
@@ -144,9 +154,11 @@ async function createServer(opts) {
|
|
|
144
154
|
(opts.afterMiddlewares || []).forEach((m) => {
|
|
145
155
|
app.use(m.toString().includes(`{ compiler }`) ? m({ compiler }) : m);
|
|
146
156
|
});
|
|
147
|
-
app.use(
|
|
148
|
-
|
|
149
|
-
|
|
157
|
+
app.use(
|
|
158
|
+
require("@umijs/bundler-webpack/compiled/connect-history-api-fallback")({
|
|
159
|
+
index: "/"
|
|
160
|
+
})
|
|
161
|
+
);
|
|
150
162
|
app.use("/__umi_ping", (_, res) => {
|
|
151
163
|
res.end("pong");
|
|
152
164
|
});
|
|
@@ -163,13 +175,15 @@ async function createServer(opts) {
|
|
|
163
175
|
if (userConfig.https) {
|
|
164
176
|
const httpsOpts = userConfig.https;
|
|
165
177
|
if (!httpsOpts.hosts) {
|
|
166
|
-
httpsOpts.hosts = import_utils.lodash.uniq(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
178
|
+
httpsOpts.hosts = import_utils.lodash.uniq(
|
|
179
|
+
[
|
|
180
|
+
...httpsOpts.hosts || [],
|
|
181
|
+
"127.0.0.1",
|
|
182
|
+
"localhost",
|
|
183
|
+
opts.ip,
|
|
184
|
+
opts.host !== "0.0.0.0" && opts.host
|
|
185
|
+
].filter(Boolean)
|
|
186
|
+
);
|
|
173
187
|
}
|
|
174
188
|
server = await (0, import_bundler_utils.createHttpsServer)(app, httpsOpts);
|
|
175
189
|
} else {
|
package/dist/server/ws.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/server/ws.ts
|
|
@@ -43,8 +46,10 @@ function createWebSocketServer(server) {
|
|
|
43
46
|
});
|
|
44
47
|
wss.on("error", (e) => {
|
|
45
48
|
if (e.code !== "EADDRINUSE") {
|
|
46
|
-
console.error(
|
|
47
|
-
|
|
49
|
+
console.error(
|
|
50
|
+
import_utils.chalk.red(`WebSocket server error:
|
|
51
|
+
${e.stack || e.message}`)
|
|
52
|
+
);
|
|
48
53
|
}
|
|
49
54
|
});
|
|
50
55
|
return {
|
|
@@ -7,7 +7,11 @@ declare class AutoCSSModule extends Visitor {
|
|
|
7
7
|
* visitProgram -> visitModule -> visitModuleItems -> visitModuleItem -> visitImportDeclaration
|
|
8
8
|
* @see https://github.com/swc-project/swc/blob/main/node-swc/src/Visitor.ts#L189
|
|
9
9
|
*/
|
|
10
|
-
visitModuleItem(n: ModuleItem): ImportDeclaration | import("@swc/core").ExportDeclaration | import("@swc/core").ExportNamedDeclaration | import("@swc/core").ExportDefaultDeclaration | import("@swc/core").ExportDefaultExpression | import("@swc/core").ExportAllDeclaration | import("@swc/core").TsImportEqualsDeclaration | import("@swc/core").TsExportAssignment | import("@swc/core").TsNamespaceExportDeclaration | import("@swc/core").
|
|
10
|
+
visitModuleItem(n: ModuleItem): ImportDeclaration | import("@swc/core").ExportDeclaration | import("@swc/core").ExportNamedDeclaration | import("@swc/core").ExportDefaultDeclaration | import("@swc/core").ExportDefaultExpression | import("@swc/core").ExportAllDeclaration | import("@swc/core").TsImportEqualsDeclaration | import("@swc/core").TsExportAssignment | import("@swc/core").TsNamespaceExportDeclaration | import("@swc/core").BlockStatement | import("@swc/core").EmptyStatement | import("@swc/core").DebuggerStatement | import("@swc/core").WithStatement | import("@swc/core").ReturnStatement | import("@swc/core").LabeledStatement | import("@swc/core").BreakStatement | import("@swc/core").ContinueStatement | import("@swc/core").IfStatement | import("@swc/core").SwitchStatement | import("@swc/core").ThrowStatement | import("@swc/core").TryStatement | import("@swc/core").WhileStatement | import("@swc/core").DoWhileStatement | import("@swc/core").ForStatement | import("@swc/core").ForInStatement | import("@swc/core").ForOfStatement | import("@swc/core").ClassDeclaration | import("@swc/core").FunctionDeclaration | import("@swc/core").VariableDeclaration | import("@swc/core").TsInterfaceDeclaration | import("@swc/core").TsTypeAliasDeclaration | import("@swc/core").TsEnumDeclaration | import("@swc/core").TsModuleDeclaration | import("@swc/core").ExpressionStatement;
|
|
11
11
|
visitImportDeclaration(expression: ImportDeclaration): ImportDeclaration;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Swc will not support js plugin in the future.
|
|
15
|
+
* See https://github.com/swc-project/website/commit/fde42ad5371c1a16ca9729fe17bcfd3489841ac1
|
|
16
|
+
*/
|
|
13
17
|
export default AutoCSSModule;
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/swcPlugins/autoCSSModules.ts
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/swcPlugins/lockCoreJS.ts
|
|
@@ -37,7 +40,10 @@ var LockCoreJS = class extends import_Visitor.default {
|
|
|
37
40
|
const { source } = expression;
|
|
38
41
|
let { value, type } = source;
|
|
39
42
|
if (type === "StringLiteral" && value.startsWith("core-js/")) {
|
|
40
|
-
const newValue = value.replace(
|
|
43
|
+
const newValue = value.replace(
|
|
44
|
+
/^core-js\//,
|
|
45
|
+
addLastSlash((0, import_utils.winPath)((0, import_path.dirname)(require.resolve("core-js/package.json"))))
|
|
46
|
+
);
|
|
41
47
|
(0, import_changeImportFromString.changeImportFromString)(expression, newValue);
|
|
42
48
|
}
|
|
43
49
|
return expression;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Options as SwcConfig } from '@swc/core';
|
|
2
2
|
import type { HttpsServerOptions, ProxyOptions } from '@umijs/bundler-utils';
|
|
3
3
|
import webpack, { Configuration } from '../compiled/webpack';
|
|
4
4
|
import Config from '../compiled/webpack-5-chain';
|
|
5
|
+
import type { TransformOptions as EsbuildOptions } from '@umijs/bundler-utils/compiled/esbuild';
|
|
6
|
+
import type { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
5
7
|
export declare enum Env {
|
|
6
8
|
development = "development",
|
|
7
9
|
production = "production"
|
|
@@ -103,6 +105,7 @@ export interface IConfig {
|
|
|
103
105
|
[key: string]: any;
|
|
104
106
|
};
|
|
105
107
|
srcTranspiler?: `${Transpiler}`;
|
|
108
|
+
srcTranspilerOptions?: ISrcTranspilerOpts;
|
|
106
109
|
styleLoader?: {
|
|
107
110
|
[key: string]: any;
|
|
108
111
|
};
|
|
@@ -117,11 +120,20 @@ export interface IConfig {
|
|
|
117
120
|
};
|
|
118
121
|
writeToDisk?: boolean;
|
|
119
122
|
babelLoaderCustomize?: string;
|
|
120
|
-
analyze?:
|
|
123
|
+
analyze?: BundleAnalyzerPlugin.Options;
|
|
121
124
|
[key: string]: any;
|
|
122
125
|
}
|
|
123
|
-
export interface
|
|
126
|
+
export interface ISrcTranspilerOpts {
|
|
127
|
+
swc?: Partial<SwcConfig>;
|
|
128
|
+
esbuild?: Partial<EsbuildOptions>;
|
|
129
|
+
}
|
|
130
|
+
export interface ISwcPluginOpts {
|
|
131
|
+
enableAutoCssModulesPlugin?: boolean;
|
|
132
|
+
}
|
|
133
|
+
export interface SwcOptions extends SwcConfig, ISwcPluginOpts {
|
|
124
134
|
sync?: boolean;
|
|
125
135
|
parseMap?: boolean;
|
|
136
|
+
excludeFiles?: Array<string | RegExp>;
|
|
137
|
+
mergeConfigs?: Partial<SwcConfig>;
|
|
126
138
|
}
|
|
127
139
|
export {};
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/utils/formatWebpackMessages.ts
|
|
@@ -46,7 +49,9 @@ function formatMessage(message) {
|
|
|
46
49
|
}
|
|
47
50
|
lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
|
|
48
51
|
lines = lines.map((line) => {
|
|
49
|
-
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
|
|
52
|
+
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
|
|
53
|
+
line
|
|
54
|
+
);
|
|
50
55
|
if (!parsingError) {
|
|
51
56
|
return line;
|
|
52
57
|
}
|
|
@@ -54,11 +59,23 @@ function formatMessage(message) {
|
|
|
54
59
|
return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
|
|
55
60
|
});
|
|
56
61
|
message = lines.join("\n");
|
|
57
|
-
message = message.replace(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
message = message.replace(
|
|
63
|
+
/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
|
|
64
|
+
`${friendlySyntaxErrorLabel} $3 ($1:$2)
|
|
65
|
+
`
|
|
66
|
+
);
|
|
67
|
+
message = message.replace(
|
|
68
|
+
/^.*export '(.+?)' was not found in '(.+?)'.*$/gm,
|
|
69
|
+
`Attempted import error: '$1' is not exported from '$2'.`
|
|
70
|
+
);
|
|
71
|
+
message = message.replace(
|
|
72
|
+
/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
|
|
73
|
+
`Attempted import error: '$2' does not contain a default export (imported as '$1').`
|
|
74
|
+
);
|
|
75
|
+
message = message.replace(
|
|
76
|
+
/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
|
|
77
|
+
`Attempted import error: '$1' is not exported from '$3' (imported as '$2').`
|
|
78
|
+
);
|
|
62
79
|
lines = message.split("\n");
|
|
63
80
|
if (lines.length > 2 && lines[1].trim() === "") {
|
|
64
81
|
lines.splice(1, 1);
|
|
@@ -75,10 +92,15 @@ function formatMessage(message) {
|
|
|
75
92
|
lines[1] += "Run `npm install sass` or `yarn add sass` inside your workspace.";
|
|
76
93
|
}
|
|
77
94
|
message = lines.join("\n");
|
|
78
|
-
message = message.replace(
|
|
95
|
+
message = message.replace(
|
|
96
|
+
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
|
|
97
|
+
""
|
|
98
|
+
);
|
|
79
99
|
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
|
|
80
100
|
lines = message.split("\n");
|
|
81
|
-
lines = lines.filter(
|
|
101
|
+
lines = lines.filter(
|
|
102
|
+
(line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
|
|
103
|
+
);
|
|
82
104
|
message = lines.join("\n");
|
|
83
105
|
return message.trim();
|
|
84
106
|
}
|
|
@@ -27,7 +27,13 @@ var import_constants = require("../constants");
|
|
|
27
27
|
var import_types = require("../types");
|
|
28
28
|
function getEsBuildTarget({ targets, jsMinifier }) {
|
|
29
29
|
if (targets["ie"] && jsMinifier === import_types.JSMinifier.esbuild) {
|
|
30
|
-
import_utils.logger.error(
|
|
30
|
+
import_utils.logger.error(
|
|
31
|
+
`${import_utils.chalk.red(
|
|
32
|
+
`jsMinifier: esbuild`
|
|
33
|
+
)} is not supported when there is ie in the targets, you can use ${import_utils.chalk.green(
|
|
34
|
+
`jsMinifier: 'terser'`
|
|
35
|
+
)}`
|
|
36
|
+
);
|
|
31
37
|
throw new Error("IE is not supported");
|
|
32
38
|
}
|
|
33
39
|
return Object.keys(targets).filter((key) => import_constants.DEFAULT_ESBUILD_TARGET_KEYS.includes(key)).map((key) => {
|