@umijs/bundler-webpack 4.0.0-canary.20220729.2 → 4.0.0-canary.20220819.1
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/compressPlugin.js +2 -1
- package/dist/config/config.d.ts +1 -1
- package/dist/config/javaScriptRules.d.ts +1 -1
- package/dist/config/javaScriptRules.js +3 -0
- package/dist/dev.d.ts +2 -0
- package/dist/dev.js +3 -1
- 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 +31 -5
- package/dist/types.d.ts +3 -3
- package/dist/utils/getEsBuildTarget.d.ts +3 -1
- package/dist/utils/getEsBuildTarget.js +7 -1
- package/package.json +5 -5
|
@@ -53,7 +53,8 @@ async function addCompressPlugin(opts) {
|
|
|
53
53
|
}
|
|
54
54
|
config.optimization.minimize(true);
|
|
55
55
|
const esbuildTarget = (0, import_getEsBuildTarget.getEsBuildTarget)({
|
|
56
|
-
targets: userConfig.targets || {}
|
|
56
|
+
targets: userConfig.targets || {},
|
|
57
|
+
jsMinifier
|
|
57
58
|
});
|
|
58
59
|
let minify;
|
|
59
60
|
let terserOptions;
|
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;
|
|
@@ -46,6 +46,9 @@ async function addJavaScriptRules(opts) {
|
|
|
46
46
|
config.module.rule("jsx-ts-tsx").test(/\.(jsx|ts|tsx)$/),
|
|
47
47
|
config.module.rule("extra-src").test(/\.(js|mjs)$/).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
|
}
|
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
|
@@ -97,7 +97,7 @@ async function dev(opts) {
|
|
|
97
97
|
publicPath: opts.config.publicPath
|
|
98
98
|
});
|
|
99
99
|
},
|
|
100
|
-
serverBase:
|
|
100
|
+
serverBase: opts.mfsuServerBase
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
const webpackConfig = await (0, import_config.getConfig)({
|
|
@@ -137,6 +137,7 @@ async function dev(opts) {
|
|
|
137
137
|
staticPathPrefix: import_mfsu.MF_DEP_PREFIX,
|
|
138
138
|
name: import_constants.MFSU_NAME,
|
|
139
139
|
chainWebpack: (_i = opts.config.mfsu) == null ? void 0 : _i.chainWebpack,
|
|
140
|
+
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
140
141
|
cache: {
|
|
141
142
|
buildDependencies: (_j = opts.cache) == null ? void 0 : _j.buildDependencies,
|
|
142
143
|
cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "mfsu-deps")
|
|
@@ -170,6 +171,7 @@ async function dev(opts) {
|
|
|
170
171
|
],
|
|
171
172
|
port: opts.port,
|
|
172
173
|
host: opts.host,
|
|
174
|
+
ip: opts.ip,
|
|
173
175
|
afterMiddlewares: [...opts.afterMiddlewares || []],
|
|
174
176
|
onDevCompileDone: opts.onDevCompileDone,
|
|
175
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) => {
|
|
@@ -162,6 +164,13 @@ async function createServer(opts) {
|
|
|
162
164
|
(0, import_assert.default)(typeof proxy2.target === "string", "proxy.target must be string");
|
|
163
165
|
(0, import_assert.default)(proxy2.context, "proxy.context must be supplied");
|
|
164
166
|
middleware = (0, import_http_proxy_middleware.createProxyMiddleware)(proxy2.context, __spreadProps(__spreadValues({}, proxy2), {
|
|
167
|
+
onProxyReq(proxyReq, req, res) {
|
|
168
|
+
var _a, _b;
|
|
169
|
+
if (proxyReq.getHeader("origin")) {
|
|
170
|
+
proxyReq.setHeader("origin", ((_a = new URL(proxy2.target)) == null ? void 0 : _a.href) || "");
|
|
171
|
+
}
|
|
172
|
+
(_b = proxy2.onProxyReq) == null ? void 0 : _b.call(proxy2, proxyReq, req, res);
|
|
173
|
+
},
|
|
165
174
|
onProxyRes(proxyRes, req, res) {
|
|
166
175
|
var _a, _b;
|
|
167
176
|
proxyRes.headers["x-real-url"] = ((_a = new URL(req.url || "", proxy2.target)) == null ? void 0 : _a.href) || "";
|
|
@@ -202,11 +211,26 @@ async function createServer(opts) {
|
|
|
202
211
|
next();
|
|
203
212
|
}
|
|
204
213
|
});
|
|
205
|
-
|
|
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
|
+
}
|
|
206
230
|
if (!server) {
|
|
207
231
|
return null;
|
|
208
232
|
}
|
|
209
|
-
|
|
233
|
+
ws = (0, import_ws.createWebSocketServer)(server);
|
|
210
234
|
ws.wss.on("connection", (socket) => {
|
|
211
235
|
if (stats) {
|
|
212
236
|
sendStats(getStats(stats), false, socket);
|
|
@@ -215,8 +239,10 @@ async function createServer(opts) {
|
|
|
215
239
|
const protocol = userConfig.https ? "https:" : "http:";
|
|
216
240
|
const port = opts.port || 8e3;
|
|
217
241
|
server.listen(port, () => {
|
|
218
|
-
const
|
|
219
|
-
|
|
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);
|
|
220
246
|
});
|
|
221
247
|
return server;
|
|
222
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;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { JSMinifier } from '../types';
|
|
1
2
|
interface IOpts {
|
|
2
3
|
targets: Record<string, any>;
|
|
4
|
+
jsMinifier: `${JSMinifier}`;
|
|
3
5
|
}
|
|
4
|
-
export declare function getEsBuildTarget({ targets }: IOpts): string[];
|
|
6
|
+
export declare function getEsBuildTarget({ targets, jsMinifier }: IOpts): string[];
|
|
5
7
|
export {};
|
|
@@ -22,8 +22,14 @@ __export(getEsBuildTarget_exports, {
|
|
|
22
22
|
getEsBuildTarget: () => getEsBuildTarget
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(getEsBuildTarget_exports);
|
|
25
|
+
var import_utils = require("@umijs/utils");
|
|
25
26
|
var import_constants = require("../constants");
|
|
26
|
-
|
|
27
|
+
var import_types = require("../types");
|
|
28
|
+
function getEsBuildTarget({ targets, jsMinifier }) {
|
|
29
|
+
if (targets["ie"] && jsMinifier === import_types.JSMinifier.esbuild) {
|
|
30
|
+
import_utils.logger.error(`${import_utils.chalk.red(`jsMinifier: esbuild`)} is not supported when there is ie in the targets, you can use ${import_utils.chalk.green(`jsMinifier: 'terser'`)}`);
|
|
31
|
+
throw new Error("IE is not supported");
|
|
32
|
+
}
|
|
27
33
|
return Object.keys(targets).filter((key) => import_constants.DEFAULT_ESBUILD_TARGET_KEYS.includes(key)).map((key) => {
|
|
28
34
|
return `${key}${targets[key] === true ? "0" : targets[key]}`;
|
|
29
35
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-webpack",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20220819.1",
|
|
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.0-canary.
|
|
38
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
37
|
+
"@umijs/babel-preset-umi": "4.0.0-canary.20220819.1",
|
|
38
|
+
"@umijs/bundler-utils": "4.0.0-canary.20220819.1",
|
|
39
39
|
"@umijs/case-sensitive-paths-webpack-plugin": "^1.0.1",
|
|
40
|
-
"@umijs/mfsu": "4.0.0-canary.
|
|
41
|
-
"@umijs/utils": "4.0.0-canary.
|
|
40
|
+
"@umijs/mfsu": "4.0.0-canary.20220819.1",
|
|
41
|
+
"@umijs/utils": "4.0.0-canary.20220819.1",
|
|
42
42
|
"cors": "^2.8.5",
|
|
43
43
|
"css-loader": "6.7.1",
|
|
44
44
|
"es5-imcompatible-versions": "^0.1.73",
|