@umijs/bundler-utoopack 4.6.44 → 4.6.46
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.js +20 -2
- package/dist/index.js +48 -17
- package/dist/util.d.ts +18 -1
- package/dist/util.js +88 -10
- package/package.json +6 -5
package/dist/config.js
CHANGED
|
@@ -300,6 +300,7 @@ async function getProdUtooPackConfig(opts) {
|
|
|
300
300
|
const userUtoopackConfig = getUserUtoopackConfig(opts.config.utoopack);
|
|
301
301
|
utooBundlerOpts = {
|
|
302
302
|
...utooBundlerOpts,
|
|
303
|
+
tracing: false,
|
|
303
304
|
config: import_utils.lodash.merge(
|
|
304
305
|
import_utils.lodash.omit(utooBundlerOpts.config, ["define"]),
|
|
305
306
|
{
|
|
@@ -397,6 +398,12 @@ async function getDevUtooPackConfig(opts) {
|
|
|
397
398
|
const userUtoopackConfig = getUserUtoopackConfig(opts.config.utoopack);
|
|
398
399
|
utooBundlerOpts = {
|
|
399
400
|
...utooBundlerOpts,
|
|
401
|
+
...process.env.SOCKET_SERVER ? {
|
|
402
|
+
processEnv: {
|
|
403
|
+
...utooBundlerOpts.processEnv || {},
|
|
404
|
+
"process.env.SOCKET_SERVER": define["process.env.SOCKET_SERVER"]
|
|
405
|
+
}
|
|
406
|
+
} : {},
|
|
400
407
|
config: import_utils.lodash.merge(
|
|
401
408
|
import_utils.lodash.omit(utooBundlerOpts.config, ["define"]),
|
|
402
409
|
{
|
|
@@ -412,7 +419,11 @@ async function getDevUtooPackConfig(opts) {
|
|
|
412
419
|
)
|
|
413
420
|
},
|
|
414
421
|
optimization: {
|
|
415
|
-
modularizeImports
|
|
422
|
+
modularizeImports,
|
|
423
|
+
// Disable the options under dev for utoopack
|
|
424
|
+
// otherwise it will affect react-refresh
|
|
425
|
+
removeUnusedExports: false,
|
|
426
|
+
removeUnusedImports: false
|
|
416
427
|
},
|
|
417
428
|
styles: {
|
|
418
429
|
less: {
|
|
@@ -429,6 +440,12 @@ async function getDevUtooPackConfig(opts) {
|
|
|
429
440
|
persistentCaching: true,
|
|
430
441
|
nodePolyfill: true,
|
|
431
442
|
externals: getNormalizedExternals(userExternals),
|
|
443
|
+
...opts.config.clickToComponent ? {
|
|
444
|
+
// clickToComponent relies on source filename metadata in dev.
|
|
445
|
+
react: {
|
|
446
|
+
absoluteSourceFilename: true
|
|
447
|
+
}
|
|
448
|
+
} : {},
|
|
432
449
|
...getSvgModuleRules({ svgr, svgo, inlineLimit })
|
|
433
450
|
},
|
|
434
451
|
userUtoopackConfig
|
|
@@ -436,7 +453,8 @@ async function getDevUtooPackConfig(opts) {
|
|
|
436
453
|
watch: {
|
|
437
454
|
enable: true
|
|
438
455
|
},
|
|
439
|
-
dev: true
|
|
456
|
+
dev: true,
|
|
457
|
+
tracing: false
|
|
440
458
|
};
|
|
441
459
|
return utooBundlerOpts;
|
|
442
460
|
}
|
package/dist/index.js
CHANGED
|
@@ -53,8 +53,9 @@ function getUtoopackRootDir(cwd, utoopackConfig, findRootDir2) {
|
|
|
53
53
|
return findRootDir2(cwd);
|
|
54
54
|
}
|
|
55
55
|
async function build(opts) {
|
|
56
|
-
var _a;
|
|
56
|
+
var _a, _b, _c;
|
|
57
57
|
const { cwd, onBuildComplete } = opts;
|
|
58
|
+
const buildStartTime = Date.now();
|
|
58
59
|
const { build: utooPackBuild, findRootDir: findRootDir2 } = require("@utoo/pack");
|
|
59
60
|
const rootDir = getUtoopackRootDir(cwd, opts.config.utoopack, findRootDir2);
|
|
60
61
|
const utooPackConfig = await (0, import_config.getProdUtooPackConfig)({
|
|
@@ -85,9 +86,24 @@ async function build(opts) {
|
|
|
85
86
|
{}
|
|
86
87
|
)
|
|
87
88
|
};
|
|
89
|
+
const time = Date.now() - buildStartTime;
|
|
88
90
|
await (onBuildComplete == null ? void 0 : onBuildComplete({
|
|
89
|
-
stats
|
|
91
|
+
stats,
|
|
92
|
+
time,
|
|
93
|
+
isFirstCompile: true
|
|
90
94
|
}));
|
|
95
|
+
const absOutputPath = import_path.default.resolve(
|
|
96
|
+
cwd,
|
|
97
|
+
((_b = utooPackConfig.config.output) == null ? void 0 : _b.path) || "dist"
|
|
98
|
+
);
|
|
99
|
+
console.log(
|
|
100
|
+
(0, import_util.getBuildBanner)({
|
|
101
|
+
packVersion: process.env.UTOOPACK_VERSION,
|
|
102
|
+
duration: time,
|
|
103
|
+
outputPath: import_path.default.relative(cwd, absOutputPath) || ".",
|
|
104
|
+
assetCount: (_c = stats.assets) == null ? void 0 : _c.length
|
|
105
|
+
})
|
|
106
|
+
);
|
|
91
107
|
return stats;
|
|
92
108
|
}
|
|
93
109
|
async function dev(opts) {
|
|
@@ -95,6 +111,8 @@ async function dev(opts) {
|
|
|
95
111
|
if (!opts) {
|
|
96
112
|
throw new Error("opts should be supplied");
|
|
97
113
|
}
|
|
114
|
+
const devStartTime = Date.now();
|
|
115
|
+
const protocol = opts.config.https ? "https:" : "http:";
|
|
98
116
|
const { findRootDir: findRootDir2, serve: utooPackServe } = require("@utoo/pack");
|
|
99
117
|
const rootDir = getUtoopackRootDir(cwd, opts.config.utoopack, findRootDir2);
|
|
100
118
|
const utooPackConfig = await (0, import_config.getDevUtooPackConfig)({
|
|
@@ -182,15 +200,12 @@ async function dev(opts) {
|
|
|
182
200
|
} else {
|
|
183
201
|
server = import_http.default.createServer(app);
|
|
184
202
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
opts.ip ?? "0.0.0.0"
|
|
192
|
-
);
|
|
193
|
-
console.log(banner);
|
|
203
|
+
const serverReady = new Promise((resolve, reject) => {
|
|
204
|
+
server.once("error", reject);
|
|
205
|
+
server.listen(port, () => {
|
|
206
|
+
server.off("error", reject);
|
|
207
|
+
resolve();
|
|
208
|
+
});
|
|
194
209
|
});
|
|
195
210
|
if (wsProxy.upgrade) {
|
|
196
211
|
server.on("upgrade", wsProxy.upgrade);
|
|
@@ -221,15 +236,31 @@ async function dev(opts) {
|
|
|
221
236
|
return stats;
|
|
222
237
|
};
|
|
223
238
|
try {
|
|
224
|
-
await
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
239
|
+
await Promise.all([
|
|
240
|
+
serverReady,
|
|
241
|
+
utooPackServe(utooPackConfig, cwd, rootDir, {
|
|
242
|
+
port: utooServePort,
|
|
243
|
+
hostname: "127.0.0.1",
|
|
244
|
+
logServerInfo: false
|
|
245
|
+
})
|
|
246
|
+
]);
|
|
247
|
+
const time = Date.now() - devStartTime;
|
|
229
248
|
const stats = createStatsObject();
|
|
230
249
|
await (onDevCompileDone == null ? void 0 : onDevCompileDone({
|
|
231
|
-
stats
|
|
250
|
+
stats,
|
|
251
|
+
time,
|
|
252
|
+
isFirstCompile: true
|
|
232
253
|
}));
|
|
254
|
+
console.log(
|
|
255
|
+
(0, import_util.getDevBanner)({
|
|
256
|
+
protocol,
|
|
257
|
+
host: opts.host,
|
|
258
|
+
port,
|
|
259
|
+
ip: opts.ip,
|
|
260
|
+
packVersion: process.env.UTOOPACK_VERSION,
|
|
261
|
+
duration: time
|
|
262
|
+
})
|
|
263
|
+
);
|
|
233
264
|
return stats;
|
|
234
265
|
} catch (e) {
|
|
235
266
|
console.error(e.message);
|
package/dist/util.d.ts
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
declare type IDevBannerOpts = {
|
|
2
|
+
duration?: number;
|
|
3
|
+
host?: string;
|
|
4
|
+
ip?: string;
|
|
5
|
+
packVersion?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
protocol: string;
|
|
8
|
+
};
|
|
9
|
+
declare type IBuildBannerOpts = {
|
|
10
|
+
assetCount?: number;
|
|
11
|
+
duration?: number;
|
|
12
|
+
outputPath?: string;
|
|
13
|
+
packVersion?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function getPackVersion(packVersion?: string): any;
|
|
16
|
+
export declare function getDevBanner({ protocol, host, port, ip, packVersion, duration, }: IDevBannerOpts): string;
|
|
17
|
+
export declare function getBuildBanner({ packVersion, duration, outputPath, assetCount, }: IBuildBannerOpts): string;
|
|
18
|
+
export {};
|
package/dist/util.js
CHANGED
|
@@ -19,21 +19,99 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/util.ts
|
|
20
20
|
var util_exports = {};
|
|
21
21
|
__export(util_exports, {
|
|
22
|
-
|
|
22
|
+
getBuildBanner: () => getBuildBanner,
|
|
23
|
+
getDevBanner: () => getDevBanner,
|
|
24
|
+
getPackVersion: () => getPackVersion
|
|
23
25
|
});
|
|
24
26
|
module.exports = __toCommonJS(util_exports);
|
|
25
27
|
var import_utils = require("@umijs/utils");
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
function getPackVersion(packVersion) {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
if (packVersion) {
|
|
31
|
+
return packVersion;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const pkg = require("../package.json");
|
|
35
|
+
return (_b = (_a = pkg.dependencies) == null ? void 0 : _a["@utoo/pack"]) == null ? void 0 : _b.replace(/^[^\d]*/, "");
|
|
36
|
+
} catch {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function formatDuration(duration) {
|
|
41
|
+
if (typeof duration !== "number") {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
return `${Math.max(0, Math.round(duration))}ms`;
|
|
45
|
+
}
|
|
46
|
+
function getDevBanner({
|
|
47
|
+
protocol,
|
|
48
|
+
host,
|
|
49
|
+
port,
|
|
50
|
+
ip,
|
|
51
|
+
packVersion,
|
|
52
|
+
duration
|
|
53
|
+
}) {
|
|
54
|
+
const hostStr = !host || host === "0.0.0.0" ? "localhost" : host;
|
|
55
|
+
const resolvedPackVersion = getPackVersion(packVersion);
|
|
56
|
+
const readyTime = formatDuration(duration);
|
|
57
|
+
const header = [
|
|
58
|
+
import_utils.chalk.cyan.bold("utoo pack"),
|
|
59
|
+
resolvedPackVersion ? import_utils.chalk.blueBright(`v${resolvedPackVersion}`) : null,
|
|
60
|
+
import_utils.chalk.green("ready"),
|
|
61
|
+
readyTime ? import_utils.chalk.dim(`in ${readyTime}`) : null
|
|
62
|
+
].filter(Boolean).join(" ");
|
|
63
|
+
const messages = [
|
|
64
|
+
"",
|
|
65
|
+
` ${header}`,
|
|
66
|
+
"",
|
|
67
|
+
` ${import_utils.chalk.green("➜")} Local: ${import_utils.chalk.cyan(
|
|
68
|
+
`${protocol}//${hostStr}:${port}`
|
|
69
|
+
)}`
|
|
70
|
+
];
|
|
71
|
+
if (ip && ip !== "0.0.0.0" && ip !== hostStr) {
|
|
72
|
+
messages.push(
|
|
73
|
+
` ${import_utils.chalk.green("➜")} Network: ${import_utils.chalk.cyan(
|
|
74
|
+
`${protocol}//${ip}:${port}`
|
|
75
|
+
)}`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return messages.join("\n");
|
|
79
|
+
}
|
|
80
|
+
function getBuildBanner({
|
|
81
|
+
packVersion,
|
|
82
|
+
duration,
|
|
83
|
+
outputPath,
|
|
84
|
+
assetCount
|
|
85
|
+
}) {
|
|
86
|
+
const resolvedPackVersion = getPackVersion(packVersion);
|
|
87
|
+
const builtTime = formatDuration(duration);
|
|
88
|
+
const messages = [
|
|
89
|
+
"",
|
|
90
|
+
` ${[
|
|
91
|
+
import_utils.chalk.cyan.bold("utoo pack"),
|
|
92
|
+
resolvedPackVersion ? import_utils.chalk.blueBright(`v${resolvedPackVersion}`) : null,
|
|
93
|
+
import_utils.chalk.green("built"),
|
|
94
|
+
builtTime ? import_utils.chalk.dim(`in ${builtTime}`) : null
|
|
95
|
+
].filter(Boolean).join(" ")}`
|
|
96
|
+
];
|
|
97
|
+
if (outputPath || typeof assetCount === "number") {
|
|
98
|
+
messages.push("");
|
|
99
|
+
}
|
|
100
|
+
if (outputPath) {
|
|
101
|
+
messages.push(` ${import_utils.chalk.green("➜")} Output: ${import_utils.chalk.cyan(outputPath)}`);
|
|
102
|
+
}
|
|
103
|
+
if (typeof assetCount === "number") {
|
|
104
|
+
messages.push(
|
|
105
|
+
` ${import_utils.chalk.green("➜")} Assets: ${import_utils.chalk.cyan(
|
|
106
|
+
`${assetCount} file${assetCount === 1 ? "" : "s"}`
|
|
107
|
+
)}`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
34
110
|
return messages.join("\n");
|
|
35
111
|
}
|
|
36
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
113
|
0 && (module.exports = {
|
|
38
|
-
|
|
114
|
+
getBuildBanner,
|
|
115
|
+
getDevBanner,
|
|
116
|
+
getPackVersion
|
|
39
117
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-utoopack",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.46",
|
|
4
4
|
"description": "@umijs/bundler-utoopack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@utoo/pack": "1.
|
|
11
|
+
"@utoo/pack": "1.4.0-alpha.4",
|
|
12
12
|
"compression": "^1.7.4",
|
|
13
13
|
"connect-history-api-fallback": "^2.0.0",
|
|
14
14
|
"cors": "^2.8.5",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"resolve-url-loader": "5.0.0",
|
|
21
21
|
"sass": "1.54.0",
|
|
22
22
|
"sass-loader": "13.2.0",
|
|
23
|
-
"@umijs/bundler-
|
|
24
|
-
"@umijs/bundler-
|
|
23
|
+
"@umijs/bundler-webpack": "4.6.46",
|
|
24
|
+
"@umijs/bundler-utils": "4.6.46"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"father": "4.1.5"
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "father build",
|
|
34
34
|
"build:deps": "umi-scripts bundleDeps",
|
|
35
|
-
"dev": "father dev"
|
|
35
|
+
"dev": "father dev",
|
|
36
|
+
"test": "umi-scripts jest-turbo"
|
|
36
37
|
}
|
|
37
38
|
}
|