@umijs/bundler-webpack 4.0.11 → 4.0.14
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/config/assetRules.js +1 -1
- package/dist/config/config.d.ts +1 -1
- package/dist/config/config.js +1 -0
- package/dist/config/javaScriptRules.d.ts +1 -1
- package/dist/config/javaScriptRules.js +6 -3
- package/dist/dev.d.ts +2 -0
- package/dist/dev.js +4 -6
- package/dist/plugins/RuntimePublicPathPlugin.js +1 -1
- package/dist/schema.js +1 -1
- package/dist/server/server.d.ts +1 -0
- package/dist/server/server.js +24 -5
- package/dist/types.d.ts +3 -3
- package/package.json +5 -5
|
@@ -36,7 +36,7 @@ async function addAssetRules(opts) {
|
|
|
36
36
|
maxSize: inlineLimit
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
|
-
const fallback = rule.oneOf("fallback").exclude.add(/^$/).add(/\.(js|mjs|jsx|ts|tsx)$/).add(/\.(css|less|sass|scss|stylus)$/).add(/\.html$/).add(/\.json$/);
|
|
39
|
+
const fallback = rule.oneOf("fallback").exclude.add(/^$/).add(/\.(js|mjs|cjs|jsx|ts|tsx)$/).add(/\.(css|less|sass|scss|stylus)$/).add(/\.html$/).add(/\.json$/);
|
|
40
40
|
if (userConfig.mdx) {
|
|
41
41
|
fallback.add(/\.mdx?$/);
|
|
42
42
|
}
|
package/dist/config/config.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface IOpts {
|
|
|
7
7
|
entry: Record<string, string>;
|
|
8
8
|
extraBabelPresets?: any[];
|
|
9
9
|
extraBabelPlugins?: any[];
|
|
10
|
-
extraBabelIncludes?: string
|
|
10
|
+
extraBabelIncludes?: Array<string | RegExp>;
|
|
11
11
|
extraEsbuildLoaderHandler?: any[];
|
|
12
12
|
babelPreset?: any;
|
|
13
13
|
chainWebpack?: Function;
|
package/dist/config/config.js
CHANGED
|
@@ -39,13 +39,16 @@ async function addJavaScriptRules(opts) {
|
|
|
39
39
|
const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== import_constants.MFSU_NAME;
|
|
40
40
|
const depPkgs = Object.assign({}, (0, import_depMatch.es5ImcompatibleVersionsToPkg)());
|
|
41
41
|
const srcRules = [
|
|
42
|
-
config.module.rule("src").test(/\.(js|mjs)$/).include.add([
|
|
42
|
+
config.module.rule("src").test(/\.(js|mjs|cjs)$/).include.add([
|
|
43
43
|
cwd,
|
|
44
44
|
...process.env.APP_ROOT ? [process.cwd()] : []
|
|
45
45
|
]).end().exclude.add(/node_modules/).end(),
|
|
46
46
|
config.module.rule("jsx-ts-tsx").test(/\.(jsx|ts|tsx)$/),
|
|
47
|
-
config.module.rule("extra-src").test(/\.(js|mjs)$/).include.add([
|
|
47
|
+
config.module.rule("extra-src").test(/\.(js|mjs|cjs)$/).include.add([
|
|
48
48
|
...opts.extraBabelIncludes.map((p) => {
|
|
49
|
+
if (import_utils.lodash.isRegExp(p)) {
|
|
50
|
+
return p;
|
|
51
|
+
}
|
|
49
52
|
if ((0, import_path.isAbsolute)(p)) {
|
|
50
53
|
return p;
|
|
51
54
|
}
|
|
@@ -77,7 +80,7 @@ async function addJavaScriptRules(opts) {
|
|
|
77
80
|
srcRules.push(config.module.rule("markdown").test(/\.mdx?$/));
|
|
78
81
|
}
|
|
79
82
|
const depRules = [
|
|
80
|
-
config.module.rule("dep").test(/\.(js|mjs)$/).include.add(/node_modules/).end().exclude.add((path) => {
|
|
83
|
+
config.module.rule("dep").test(/\.(js|mjs|cjs)$/).include.add(/node_modules/).end().exclude.add((path) => {
|
|
81
84
|
try {
|
|
82
85
|
return (0, import_depMatch.isMatch)({ path, pkgs: depPkgs });
|
|
83
86
|
} catch (e) {
|
package/dist/dev.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare type IOpts = {
|
|
|
8
8
|
onMFSUProgress?: Function;
|
|
9
9
|
port?: number;
|
|
10
10
|
host?: string;
|
|
11
|
+
ip?: string;
|
|
11
12
|
babelPreset?: any;
|
|
12
13
|
chainWebpack?: Function;
|
|
13
14
|
modifyWebpackConfig?: Function;
|
|
@@ -21,6 +22,7 @@ declare type IOpts = {
|
|
|
21
22
|
entry: Record<string, string>;
|
|
22
23
|
mfsuStrategy?: 'eager' | 'normal';
|
|
23
24
|
mfsuInclude?: string[];
|
|
25
|
+
mfsuServerBase?: string;
|
|
24
26
|
srcCodeCache?: any;
|
|
25
27
|
} & Pick<IConfigOpts, 'cache' | 'pkg'>;
|
|
26
28
|
export declare function stripUndefined(obj: any): any;
|
package/dist/dev.js
CHANGED
|
@@ -65,10 +65,6 @@ async function dev(opts) {
|
|
|
65
65
|
const cacheDirectoryPath = (0, import_path.resolve)(opts.rootDir || opts.cwd, opts.config.cacheDirectoryPath || "node_modules/.cache");
|
|
66
66
|
const enableMFSU = opts.config.mfsu !== false;
|
|
67
67
|
let mfsu = null;
|
|
68
|
-
let devHost = "localhost";
|
|
69
|
-
if (opts.host && opts.host !== "0.0.0.0") {
|
|
70
|
-
devHost = opts.host;
|
|
71
|
-
}
|
|
72
68
|
if (enableMFSU) {
|
|
73
69
|
if (opts.config.srcTranspiler === import_types.Transpiler.swc) {
|
|
74
70
|
import_utils.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
|
|
@@ -101,7 +97,7 @@ async function dev(opts) {
|
|
|
101
97
|
publicPath: opts.config.publicPath
|
|
102
98
|
});
|
|
103
99
|
},
|
|
104
|
-
serverBase:
|
|
100
|
+
serverBase: opts.mfsuServerBase
|
|
105
101
|
});
|
|
106
102
|
}
|
|
107
103
|
const webpackConfig = await (0, import_config.getConfig)({
|
|
@@ -141,6 +137,7 @@ async function dev(opts) {
|
|
|
141
137
|
staticPathPrefix: import_mfsu.MF_DEP_PREFIX,
|
|
142
138
|
name: import_constants.MFSU_NAME,
|
|
143
139
|
chainWebpack: (_i = opts.config.mfsu) == null ? void 0 : _i.chainWebpack,
|
|
140
|
+
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
144
141
|
cache: {
|
|
145
142
|
buildDependencies: (_j = opts.cache) == null ? void 0 : _j.buildDependencies,
|
|
146
143
|
cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "mfsu-deps")
|
|
@@ -173,7 +170,8 @@ async function dev(opts) {
|
|
|
173
170
|
...opts.beforeMiddlewares || []
|
|
174
171
|
],
|
|
175
172
|
port: opts.port,
|
|
176
|
-
host:
|
|
173
|
+
host: opts.host,
|
|
174
|
+
ip: opts.ip,
|
|
177
175
|
afterMiddlewares: [...opts.afterMiddlewares || []],
|
|
178
176
|
onDevCompileDone: opts.onDevCompileDone,
|
|
179
177
|
onProgress: opts.onProgress
|
|
@@ -30,7 +30,7 @@ var RuntimePublicPathPlugin = class {
|
|
|
30
30
|
if (module2.constructor.name === "PublicPathRuntimeModule") {
|
|
31
31
|
if (module2.getGeneratedCode().includes("webpack:///mini-css-extract-plugin"))
|
|
32
32
|
return;
|
|
33
|
-
module2._cachedGeneratedCode = `__webpack_require__.p = (typeof globalThis !== undefined ? globalThis : window).publicPath || '/';`;
|
|
33
|
+
module2._cachedGeneratedCode = `__webpack_require__.p = (typeof globalThis !== 'undefined' ? globalThis : window).publicPath || '/';`;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
});
|
package/dist/schema.js
CHANGED
|
@@ -73,7 +73,7 @@ function getSchemas() {
|
|
|
73
73
|
devtool: (Joi) => Joi.alternatives().try(Joi.string().regex(DEVTOOL_REGEX), Joi.boolean()),
|
|
74
74
|
esm: (Joi) => Joi.object(),
|
|
75
75
|
externals: (Joi) => Joi.alternatives().try(Joi.object(), Joi.string(), Joi.func()),
|
|
76
|
-
extraBabelIncludes: (Joi) => Joi.array().items(Joi.string()),
|
|
76
|
+
extraBabelIncludes: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.object().instance(RegExp))),
|
|
77
77
|
extraBabelPlugins: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.array())),
|
|
78
78
|
extraBabelPresets: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.array())),
|
|
79
79
|
extraPostCSSPlugins: (Joi) => Joi.array(),
|
package/dist/server/server.d.ts
CHANGED
package/dist/server/server.js
CHANGED
|
@@ -58,6 +58,7 @@ async function createServer(opts) {
|
|
|
58
58
|
const { webpackConfig, userConfig } = opts;
|
|
59
59
|
const { proxy } = userConfig;
|
|
60
60
|
const app = (0, import_express.default)();
|
|
61
|
+
let ws;
|
|
61
62
|
app.use((0, import_cors.default)({
|
|
62
63
|
origin: true,
|
|
63
64
|
methods: ["GET", "HEAD", "PUT", "POST", "PATCH", "DELETE", "OPTIONS"],
|
|
@@ -148,7 +149,8 @@ async function createServer(opts) {
|
|
|
148
149
|
});
|
|
149
150
|
}
|
|
150
151
|
function sendMessage(type, data, sender) {
|
|
151
|
-
|
|
152
|
+
var _a;
|
|
153
|
+
(_a = sender || ws) == null ? void 0 : _a.send(JSON.stringify({ type, data }));
|
|
152
154
|
}
|
|
153
155
|
if (proxy) {
|
|
154
156
|
const proxyArr = Array.isArray(proxy) ? proxy : proxy.target ? [proxy] : Object.keys(proxy).map((key) => {
|
|
@@ -209,11 +211,26 @@ async function createServer(opts) {
|
|
|
209
211
|
next();
|
|
210
212
|
}
|
|
211
213
|
});
|
|
212
|
-
|
|
214
|
+
let server;
|
|
215
|
+
if (userConfig.https) {
|
|
216
|
+
const httpsOpts = userConfig.https;
|
|
217
|
+
if (!httpsOpts.hosts) {
|
|
218
|
+
httpsOpts.hosts = import_utils.lodash.uniq([
|
|
219
|
+
...httpsOpts.hosts || [],
|
|
220
|
+
"127.0.0.1",
|
|
221
|
+
"localhost",
|
|
222
|
+
opts.ip,
|
|
223
|
+
opts.host !== "0.0.0.0" && opts.host
|
|
224
|
+
].filter(Boolean));
|
|
225
|
+
}
|
|
226
|
+
server = await (0, import_bundler_utils.createHttpsServer)(app, httpsOpts);
|
|
227
|
+
} else {
|
|
228
|
+
server = import_http.default.createServer(app);
|
|
229
|
+
}
|
|
213
230
|
if (!server) {
|
|
214
231
|
return null;
|
|
215
232
|
}
|
|
216
|
-
|
|
233
|
+
ws = (0, import_ws.createWebSocketServer)(server);
|
|
217
234
|
ws.wss.on("connection", (socket) => {
|
|
218
235
|
if (stats) {
|
|
219
236
|
sendStats(getStats(stats), false, socket);
|
|
@@ -222,8 +239,10 @@ async function createServer(opts) {
|
|
|
222
239
|
const protocol = userConfig.https ? "https:" : "http:";
|
|
223
240
|
const port = opts.port || 8e3;
|
|
224
241
|
server.listen(port, () => {
|
|
225
|
-
const
|
|
226
|
-
|
|
242
|
+
const banner = (0, import_utils.getDevBanner)(protocol, opts.host, port);
|
|
243
|
+
console.log(banner.before);
|
|
244
|
+
import_utils.logger.ready(banner.main);
|
|
245
|
+
console.log(banner.after);
|
|
227
246
|
});
|
|
228
247
|
return server;
|
|
229
248
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -54,14 +54,14 @@ export interface IConfig {
|
|
|
54
54
|
cssLoaderModules?: {
|
|
55
55
|
[key: string]: any;
|
|
56
56
|
};
|
|
57
|
-
cssMinifier?: CSSMinifier
|
|
57
|
+
cssMinifier?: `${CSSMinifier}`;
|
|
58
58
|
cssMinifierOptions?: {
|
|
59
59
|
[key: string]: any;
|
|
60
60
|
};
|
|
61
61
|
define?: {
|
|
62
62
|
[key: string]: any;
|
|
63
63
|
};
|
|
64
|
-
depTranspiler?: Transpiler
|
|
64
|
+
depTranspiler?: `${Transpiler}`;
|
|
65
65
|
devtool?: Config.DevTool;
|
|
66
66
|
deadCode?: DeadCodeParams;
|
|
67
67
|
https?: HttpsServerOptions;
|
|
@@ -71,7 +71,7 @@ export interface IConfig {
|
|
|
71
71
|
};
|
|
72
72
|
extraBabelPlugins?: IBabelPlugin[];
|
|
73
73
|
extraBabelPresets?: IBabelPlugin[];
|
|
74
|
-
extraBabelIncludes?: string
|
|
74
|
+
extraBabelIncludes?: Array<string | RegExp>;
|
|
75
75
|
extraPostCSSPlugins?: any[];
|
|
76
76
|
hash?: boolean;
|
|
77
77
|
ignoreMomentLocale?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-webpack",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.14",
|
|
4
4
|
"description": "@umijs/bundler-webpack",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-webpack#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"@svgr/plugin-jsx": "^6.2.1",
|
|
35
35
|
"@svgr/plugin-svgo": "^6.2.0",
|
|
36
36
|
"@types/hapi__joi": "17.1.8",
|
|
37
|
-
"@umijs/babel-preset-umi": "4.0.
|
|
38
|
-
"@umijs/bundler-utils": "4.0.
|
|
37
|
+
"@umijs/babel-preset-umi": "4.0.14",
|
|
38
|
+
"@umijs/bundler-utils": "4.0.14",
|
|
39
39
|
"@umijs/case-sensitive-paths-webpack-plugin": "^1.0.1",
|
|
40
|
-
"@umijs/mfsu": "4.0.
|
|
41
|
-
"@umijs/utils": "4.0.
|
|
40
|
+
"@umijs/mfsu": "4.0.14",
|
|
41
|
+
"@umijs/utils": "4.0.14",
|
|
42
42
|
"cors": "^2.8.5",
|
|
43
43
|
"css-loader": "6.7.1",
|
|
44
44
|
"es5-imcompatible-versions": "^0.1.73",
|