@unpackjs/core 3.2.7 → 3.3.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/compiled/css-loader/index.js +20 -20
- package/compiled/less-loader/index.js +8 -8
- package/compiled/postcss-loader/index.js +8 -8
- package/compiled/sass-loader/index.js +8 -8
- package/dist/index.cjs +271 -233
- package/dist/index.js +269 -236
- package/dist/typedCssModulesLoader.mjs +5 -13
- package/dist-types/bundler-config/index.d.ts.map +1 -1
- package/dist-types/bundler-config/plugins/oxlint/index.d.ts +0 -3
- package/dist-types/bundler-config/plugins/oxlint/index.d.ts.map +1 -1
- package/dist-types/bundler-config/plugins/progress/helpers.d.ts +0 -1
- package/dist-types/bundler-config/plugins/progress/helpers.d.ts.map +1 -1
- package/dist-types/bundler-config/plugins/progress/index.d.ts.map +1 -1
- package/dist-types/cliShortcuts.d.ts +22 -0
- package/dist-types/cliShortcuts.d.ts.map +1 -0
- package/dist-types/config.d.ts.map +1 -1
- package/dist-types/createUnpack.d.ts.map +1 -1
- package/dist-types/global.d.ts +7 -1
- package/dist-types/global.d.ts.map +1 -1
- package/dist-types/index.d.ts +1 -0
- package/dist-types/index.d.ts.map +1 -1
- package/dist-types/logger.d.ts.map +1 -1
- package/dist-types/prebundleDeps.d.ts.map +1 -1
- package/dist-types/run/dev.d.ts.map +1 -1
- package/dist-types/types/config.d.ts +4 -2
- package/dist-types/types/config.d.ts.map +1 -1
- package/dist-types/types/index.d.ts +1 -0
- package/dist-types/types/index.d.ts.map +1 -1
- package/dist-types/types/logger.d.ts +2 -2
- package/dist-types/types/logger.d.ts.map +1 -1
- package/dist-types/utils.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
let lastTrackTime, lastFileInfo, logger;
|
|
1
2
|
import __rslib_shim_module__ from 'module';
|
|
2
3
|
let require = __rslib_shim_module__.createRequire(import.meta.url);
|
|
3
4
|
import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
|
|
@@ -6,14 +7,14 @@ import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_bundle_analyzer_index_js
|
|
|
6
7
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_merge_index_js_efd91626__ from "../compiled/webpack-merge/index.js";
|
|
7
8
|
import { experiments, rspack } from "@rspack/core";
|
|
8
9
|
import picocolors from "picocolors";
|
|
9
|
-
import node_fs from "node:fs";
|
|
10
|
-
import node_path, { join, sep } from "node:path";
|
|
11
|
-
import { pathToFileURL } from "node:url";
|
|
12
|
-
import { createJiti } from "jiti";
|
|
13
10
|
import node_readline from "node:readline";
|
|
11
|
+
import node_fs from "node:fs";
|
|
14
12
|
import node_net from "node:net";
|
|
15
13
|
import node_os, { platform } from "node:os";
|
|
14
|
+
import node_path, { join, sep } from "node:path";
|
|
16
15
|
import portfinder from "portfinder";
|
|
16
|
+
import { pathToFileURL } from "node:url";
|
|
17
|
+
import { createJiti } from "jiti";
|
|
17
18
|
import { expand } from "dotenv-expand";
|
|
18
19
|
import { TsCheckerRspackPlugin } from "ts-checker-rspack-plugin";
|
|
19
20
|
import node_assert from "node:assert";
|
|
@@ -22,9 +23,9 @@ import typed_css_modules from "typed-css-modules";
|
|
|
22
23
|
import { exec, spawn } from "node:child_process";
|
|
23
24
|
import { promisify } from "node:util";
|
|
24
25
|
import node_zlib from "node:zlib";
|
|
26
|
+
import { RspackDevServer } from "@rspack/dev-server";
|
|
25
27
|
import cors from "cors";
|
|
26
28
|
import express from "express";
|
|
27
|
-
import webpack_dev_server from "webpack-dev-server";
|
|
28
29
|
import chokidar from "chokidar";
|
|
29
30
|
var LogColor, __webpack_modules__ = {
|
|
30
31
|
"compiled/webpack-bundle-analyzer": function(module) {
|
|
@@ -51,8 +52,14 @@ let colors = {
|
|
|
51
52
|
for (let char of chars)isWord(char) && (r += rStep, g += gStep, b += bStep), output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
|
|
52
53
|
return output;
|
|
53
54
|
}
|
|
55
|
+
}, restartCleaners = [], addRestartCleaner = (...cleaners)=>{
|
|
56
|
+
restartCleaners.push(...cleaners);
|
|
57
|
+
}, cleanUpBeforeRestart = async ()=>{
|
|
58
|
+
await Promise.all(restartCleaners.map((cleaner)=>cleaner())), restartCleaners.length = 0;
|
|
59
|
+
}, currentDevUnpackConfig = {}, setCurrentDevUnpackConfig = (config)=>{
|
|
60
|
+
currentDevUnpackConfig = config;
|
|
54
61
|
};
|
|
55
|
-
var logger_LogColor = ((LogColor = {}).error = "red", LogColor.warn = "yellow", LogColor.info = "cyan", LogColor.ready = "green", LogColor.event = "magenta", LogColor.wait = "blue", LogColor
|
|
62
|
+
var logger_LogColor = ((LogColor = {}).error = "red", LogColor.warn = "yellow", LogColor.info = "cyan", LogColor.ready = "green", LogColor.event = "magenta", LogColor.wait = "blue", LogColor);
|
|
56
63
|
let CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]', CSS_MODULES_REGEX = /\.module\.\w+$/i, DEV_DEFAULT_FILENAME = {
|
|
57
64
|
js: 'js/[name].js',
|
|
58
65
|
jsAsync: 'js/async/[name].js',
|
|
@@ -63,7 +70,7 @@ let CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]', CSS_MODULE
|
|
|
63
70
|
jsAsync: 'js/async/[name].[contenthash:8].js',
|
|
64
71
|
css: 'css/[name].[contenthash:8].css',
|
|
65
72
|
cssAsync: 'css/async/[name].[contenthash:8].css'
|
|
66
|
-
}, EXPORT_LOCALS_CONVENTION = 'camel-case-only', TEMP_DIR = 'node_modules/.unpack', NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/,
|
|
73
|
+
}, EXPORT_LOCALS_CONVENTION = 'camel-case-only', TEMP_DIR = 'node_modules/.unpack', NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, THREAD_OPTIONS = {
|
|
67
74
|
workers: 2
|
|
68
75
|
}, DEFAULT_DEV_HOST = '0.0.0.0', TEMPLATE_CONTENT = ({ title = '', headTag = '', mountId = '' })=>`<!DOCTYPE html>
|
|
69
76
|
<html lang="en">
|
|
@@ -177,12 +184,11 @@ let debounce = (fn, delay)=>{
|
|
|
177
184
|
});
|
|
178
185
|
return addressUrls;
|
|
179
186
|
}, trackPerformance = (msg)=>{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
global[k] = performance.now();
|
|
187
|
+
if (!lastTrackTime) {
|
|
188
|
+
lastTrackTime = performance.now();
|
|
183
189
|
return;
|
|
184
190
|
}
|
|
185
|
-
msg && console.log(` ${msg} ${colors.dim('in')} ${colors.yellow(`${(performance.now() -
|
|
191
|
+
msg && console.log(` ${msg} ${colors.dim('in')} ${colors.yellow(`${(performance.now() - lastTrackTime).toFixed(2)}ms`)}`), lastTrackTime = performance.now();
|
|
186
192
|
}, getPathInJs = (absPath)=>JSON.stringify(absPath).slice(1, -1), mergeConfig = merge, getUserDepVersion = (root, dep)=>{
|
|
187
193
|
let depPath = getUserDepPath(root, dep);
|
|
188
194
|
if (depPath) return JSON.parse(node_fs.readFileSync(node_path.resolve(depPath, 'package.json'), 'utf-8')).version;
|
|
@@ -223,50 +229,98 @@ let isCSSModules = ({ resourcePath, modules })=>{
|
|
|
223
229
|
if (!browsers) throw Error(`Unsupported ES version: ${esVersion}`);
|
|
224
230
|
return browsers;
|
|
225
231
|
}, logger_prefixes = {
|
|
226
|
-
wait:
|
|
227
|
-
error:
|
|
228
|
-
warn:
|
|
229
|
-
info:
|
|
230
|
-
ready:
|
|
231
|
-
event:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
232
|
+
wait: '○',
|
|
233
|
+
error: '⨯',
|
|
234
|
+
warn: '⚠',
|
|
235
|
+
info: 'ℹ',
|
|
236
|
+
ready: '✓',
|
|
237
|
+
event: '»'
|
|
238
|
+
}, logger_logger = (logger = {
|
|
239
|
+
clear: ()=>{
|
|
240
|
+
let repeatCount = process.stdout.rows - 2;
|
|
241
|
+
console.log(repeatCount > 0 ? '\n'.repeat(repeatCount) : ''), node_readline.cursorTo(process.stdout, 0, 0), node_readline.clearScreenDown(process.stdout);
|
|
242
|
+
},
|
|
243
|
+
greet: (msg)=>{
|
|
244
|
+
let { npm_execpath, npm_lifecycle_event } = process.env;
|
|
245
|
+
(!npm_execpath || 'npx' === npm_lifecycle_event || npm_execpath.includes('npx-cli') || npm_execpath.includes('.bun') || npm_execpath.includes('yarn')) && console.log(), console.log(msg);
|
|
246
|
+
},
|
|
247
|
+
debug: (message, ...args)=>{
|
|
248
|
+
isDebug() && console.log(`${colors.gray(colors.dim(getTime()))} ${message}`, ...args);
|
|
249
|
+
}
|
|
250
|
+
}, Object.keys(logger_prefixes).forEach((type)=>{
|
|
251
|
+
logger[type] = (message, ...args)=>{
|
|
252
|
+
((type, message, ...args)=>{
|
|
253
|
+
let label = colors[logger_LogColor[type]](logger_prefixes[type]), text = '';
|
|
254
|
+
switch(type){
|
|
255
|
+
case 'error':
|
|
256
|
+
if (message instanceof Error) if (message.stack) {
|
|
257
|
+
let [name, ...rest] = message.stack.split('\n');
|
|
258
|
+
name.startsWith('Error: ') && (name = name.slice(7), rest = rest.map((line)=>line.slice(2))), text = `${colors.red(name)}\n${colors.dim(rest.join('\n'))}`;
|
|
259
|
+
} else text = colors.red(message.message);
|
|
260
|
+
else text = colors.red(message);
|
|
261
|
+
break;
|
|
262
|
+
case 'warn':
|
|
263
|
+
text = colors.yellow(message);
|
|
264
|
+
break;
|
|
265
|
+
default:
|
|
266
|
+
text = message;
|
|
267
|
+
}
|
|
268
|
+
console.log(`${label} ${text}`, ...args);
|
|
269
|
+
})(type, message, ...args);
|
|
243
270
|
};
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
271
|
+
}), logger);
|
|
272
|
+
async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer }) {
|
|
273
|
+
let shortcuts = [
|
|
274
|
+
restartServer ? {
|
|
275
|
+
key: 'r',
|
|
276
|
+
description: 'restart server',
|
|
277
|
+
action: restartServer
|
|
278
|
+
} : null,
|
|
279
|
+
{
|
|
280
|
+
key: 'u',
|
|
281
|
+
description: 'show server url',
|
|
282
|
+
action: printUrls
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
key: 'o',
|
|
286
|
+
description: 'open in browser',
|
|
287
|
+
action: openPage
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
key: 'c',
|
|
291
|
+
description: 'clear console',
|
|
292
|
+
action: ()=>{
|
|
293
|
+
logger_logger.clear();
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
key: 'q',
|
|
298
|
+
description: 'quit',
|
|
299
|
+
action: async ()=>{
|
|
300
|
+
try {
|
|
301
|
+
await closeServer();
|
|
302
|
+
} finally{
|
|
303
|
+
process.exit(0);
|
|
264
304
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
})
|
|
269
|
-
})(
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
].filter(Boolean), colorPrefix = colors.green(colors.dim('➜'));
|
|
308
|
+
help && console.log(!0 === help ? ` ${colorPrefix} ${colors.dim('press')} ${colors.bold('h + enter')} ${colors.dim('to show help')}` : ` ${colorPrefix} ${help}`);
|
|
309
|
+
let { createInterface } = await import("node:readline"), rl = createInterface({
|
|
310
|
+
input: process.stdin
|
|
311
|
+
});
|
|
312
|
+
rl.on('line', (input)=>{
|
|
313
|
+
if ('h' === input) {
|
|
314
|
+
let message = '\n Shortcuts\n';
|
|
315
|
+
for (let shortcut of shortcuts){
|
|
316
|
+
let fullDescription = `${colors.dim('press')} ${colors.bold(`${shortcut.key} + enter`)} ${colors.dim(`to ${shortcut.description}`)}`;
|
|
317
|
+
message += ` ${fullDescription}\n`;
|
|
318
|
+
}
|
|
319
|
+
console.log(message);
|
|
320
|
+
}
|
|
321
|
+
for (let shortcut of shortcuts)if (input === shortcut.key) return void shortcut.action();
|
|
322
|
+
}), addRestartCleaner(()=>rl.close());
|
|
323
|
+
}
|
|
270
324
|
var config_filename = __webpack_fileURLToPath__(import.meta.url);
|
|
271
325
|
async function loadConfig({ cliOptions, command }) {
|
|
272
326
|
'build' === command ? setNodeEnv((null == cliOptions ? void 0 : cliOptions.watch) ? 'development' : 'production') : (setNodeEnv('development'), setDevServer(!0));
|
|
@@ -317,7 +371,10 @@ async function loadConfig({ cliOptions, command }) {
|
|
|
317
371
|
'bundleAnalyze'
|
|
318
372
|
], cliOptions.analyze), (null == cliOptions ? void 0 : cliOptions.root) && setValueByPath(configExport, [
|
|
319
373
|
'root'
|
|
320
|
-
], root), configExport
|
|
374
|
+
], root), (null == cliOptions ? void 0 : cliOptions.host) && setValueByPath(configExport, [
|
|
375
|
+
'server',
|
|
376
|
+
'host'
|
|
377
|
+
], cliOptions.host), configExport;
|
|
321
378
|
}
|
|
322
379
|
function defineConfig(config) {
|
|
323
380
|
return config;
|
|
@@ -571,7 +628,7 @@ class TypedCssModulesPlugin {
|
|
|
571
628
|
constructor(options){
|
|
572
629
|
_define_property(this, "dtsCreator", void 0), _define_property(this, "useIncremental", !1), _define_property(this, "globPattern", 'src/**/*.{css,less,scss}'), _define_property(this, "userOptions", void 0), this.userOptions = options, this.dtsCreator = new DtsCreator({
|
|
573
630
|
camelCase: !0,
|
|
574
|
-
namedExports:
|
|
631
|
+
namedExports: !1
|
|
575
632
|
});
|
|
576
633
|
}
|
|
577
634
|
}
|
|
@@ -588,7 +645,7 @@ class JsMinifyPlugin {
|
|
|
588
645
|
apply(compiler) {
|
|
589
646
|
let meta = JSON.stringify({
|
|
590
647
|
name: jsMinify_PLUGIN_NAME,
|
|
591
|
-
version: "3.
|
|
648
|
+
version: "3.3.1",
|
|
592
649
|
options: this.minifyOptions
|
|
593
650
|
});
|
|
594
651
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -624,37 +681,7 @@ class JsMinifyPlugin {
|
|
|
624
681
|
}
|
|
625
682
|
}
|
|
626
683
|
var oxlint_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
627
|
-
function oxlint_define_property(obj, key, value) {
|
|
628
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
629
|
-
value: value,
|
|
630
|
-
enumerable: !0,
|
|
631
|
-
configurable: !0,
|
|
632
|
-
writable: !0
|
|
633
|
-
}) : obj[key] = value, obj;
|
|
634
|
-
}
|
|
635
684
|
class OxlintPlugin {
|
|
636
|
-
getGitChangedFiles() {
|
|
637
|
-
return new Promise((resolve)=>{
|
|
638
|
-
var _child_stdout;
|
|
639
|
-
let child = spawn('git', [
|
|
640
|
-
'status',
|
|
641
|
-
'--porcelain'
|
|
642
|
-
], {
|
|
643
|
-
cwd: process.cwd(),
|
|
644
|
-
stdio: 'pipe'
|
|
645
|
-
}), output = '';
|
|
646
|
-
null == (_child_stdout = child.stdout) || _child_stdout.on('data', (data)=>{
|
|
647
|
-
output += data.toString();
|
|
648
|
-
}), child.on('exit', (code)=>{
|
|
649
|
-
0 === code ? resolve(output.trim().split('\n').filter(Boolean).map((line)=>{
|
|
650
|
-
let idx = line.indexOf(' '), status = line.slice(0, idx), filePath = line.slice(idx + 1).trim();
|
|
651
|
-
return status.includes('D') ? null : ((status.startsWith('R') || status.startsWith('C')) && (filePath = filePath.split(' -> ')[1]), filePath);
|
|
652
|
-
}).filter(Boolean).map((file)=>node_path.resolve(process.cwd(), file))) : resolve([]);
|
|
653
|
-
}), child.on('error', ()=>{
|
|
654
|
-
resolve([]);
|
|
655
|
-
});
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
685
|
runOxlint(args) {
|
|
659
686
|
var _child_stdout, _child_stderr;
|
|
660
687
|
let child = spawn('npx', [
|
|
@@ -672,34 +699,31 @@ class OxlintPlugin {
|
|
|
672
699
|
null == (_child_stdout = child.stdout) || _child_stdout.on('data', (data)=>{
|
|
673
700
|
output += data.toString();
|
|
674
701
|
}), child.on('exit', (code)=>{
|
|
675
|
-
output.includes('Found 0 warnings and 0 errors')
|
|
702
|
+
let hasErrors = !output.includes('Found 0 warnings and 0 errors'), hasNoFiles = output.includes('on 0 files');
|
|
703
|
+
(hasErrors || 0 !== code) && !hasNoFiles && process.stdout.write(output);
|
|
676
704
|
}), null == (_child_stderr = child.stderr) || _child_stderr.on('data', (data)=>{
|
|
677
705
|
process.stderr.write(data);
|
|
678
706
|
});
|
|
679
707
|
}
|
|
680
708
|
apply(compiler) {
|
|
681
709
|
compiler.hooks.watchRun.tap('OxlintPlugin', ()=>{
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
}, this.debounceTime);
|
|
710
|
+
let configPath = node_path.resolve(oxlint_dirname, '.oxlintrc.json'), changedFiles = compiler.modifiedFiles ? Array.from(compiler.modifiedFiles) : [];
|
|
711
|
+
if (1 === changedFiles.length) {
|
|
712
|
+
let currentFile = changedFiles[0];
|
|
713
|
+
if (node_fs.existsSync(currentFile) && node_fs.statSync(currentFile).isFile()) {
|
|
714
|
+
let args = [
|
|
715
|
+
'oxlint',
|
|
716
|
+
'-c',
|
|
717
|
+
configPath,
|
|
718
|
+
currentFile,
|
|
719
|
+
'--fix',
|
|
720
|
+
'--fix-suggestions'
|
|
721
|
+
];
|
|
722
|
+
this.runOxlint(args);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
698
725
|
});
|
|
699
726
|
}
|
|
700
|
-
constructor(){
|
|
701
|
-
oxlint_define_property(this, "timeoutId", null), oxlint_define_property(this, "debounceTime", 200);
|
|
702
|
-
}
|
|
703
727
|
}
|
|
704
728
|
function loadingAnimation_define_property(obj, key, value) {
|
|
705
729
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
@@ -719,16 +743,16 @@ class LoadingAnimation {
|
|
|
719
743
|
}
|
|
720
744
|
constructor(){
|
|
721
745
|
loadingAnimation_define_property(this, "chars", [
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
746
|
+
'⠋',
|
|
747
|
+
'⠙',
|
|
748
|
+
'⠹',
|
|
749
|
+
'⠸',
|
|
750
|
+
'⠼',
|
|
751
|
+
'⠴',
|
|
752
|
+
'⠦',
|
|
753
|
+
'⠧',
|
|
754
|
+
'⠇',
|
|
755
|
+
'⠏'
|
|
732
756
|
]), loadingAnimation_define_property(this, "currentIndex", 0), loadingAnimation_define_property(this, "lastUpdateTime", 0), loadingAnimation_define_property(this, "interval", 100);
|
|
733
757
|
}
|
|
734
758
|
}
|
|
@@ -794,7 +818,7 @@ async function printFileSize({ root, stats }) {
|
|
|
794
818
|
}), longest = 0, totalSize = 0, totalCompressedSize = 0;
|
|
795
819
|
await Promise.all(origin.assets.map(async (asset)=>{
|
|
796
820
|
let content = await node_fs.promises.readFile(node_path.join(distPath, asset.name)), size = content.length, compressedSize = await getCompressedSize(content);
|
|
797
|
-
totalSize += size, totalCompressedSize += compressedSize, compressedCount++, logUpdate(`${loadingAnimation.getCurrentChar()} computing gzip size (${compressedCount})...`), compressedCount === origin.assets.length && (logUpdate(
|
|
821
|
+
totalSize += size, totalCompressedSize += compressedSize, compressedCount++, logUpdate(`${loadingAnimation.getCurrentChar()} computing gzip size (${compressedCount})...`), compressedCount === origin.assets.length && (logUpdate(`✓ computed gzip size (${compressedCount})`), console.log());
|
|
798
822
|
let chunk = {
|
|
799
823
|
name: node_path.basename(asset.name),
|
|
800
824
|
path: `${distFolder}/${asset.name}`,
|
|
@@ -820,11 +844,11 @@ async function printFileSize({ root, stats }) {
|
|
|
820
844
|
chunkGroups.forEach((group)=>{
|
|
821
845
|
group.chunks.sort((a, b)=>a.size - b.size).forEach((chunk)=>{
|
|
822
846
|
let isLarge = 'JS' === group.type && chunk.size / 1000 > 500, relativeOutDir = node_path.dirname(chunk.path) + '/', log = colors.dim(relativeOutDir);
|
|
823
|
-
log += colors[group.color](chunk.name.padEnd(longest + 2 - relativeOutDir.length)), log += colors[isLarge ? 'yellow' : 'dim'](displaySize(chunk.size).padStart(sizePad)), chunk.compressedSize && (log += colors.dim(`
|
|
847
|
+
log += colors[group.color](chunk.name.padEnd(longest + 2 - relativeOutDir.length)), log += colors[isLarge ? 'yellow' : 'dim'](displaySize(chunk.size).padStart(sizePad)), chunk.compressedSize && (log += colors.dim(` │ gzip: ${displaySize(chunk.compressedSize).padStart(compressPad)}`)), console.log(log);
|
|
824
848
|
});
|
|
825
849
|
});
|
|
826
850
|
let log = colors.blue('Total'.padEnd(longest + 2));
|
|
827
|
-
log += colors.blue(displaySize(totalSize)), console.log(log += colors.dim(`
|
|
851
|
+
log += colors.blue(displaySize(totalSize)), console.log(log += colors.dim(` │ gzip: ${displaySize(totalCompressedSize)}`));
|
|
828
852
|
}
|
|
829
853
|
function isLikelyFile(filePath) {
|
|
830
854
|
return (filePath.split(sep).pop() || '').includes('.');
|
|
@@ -834,29 +858,13 @@ function formatFileList(paths, rootPath) {
|
|
|
834
858
|
0 === files.length && (files = [
|
|
835
859
|
paths[0]
|
|
836
860
|
]);
|
|
837
|
-
let fileInfo = files.slice(0, 1).map((file)=>
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
return parts.length > 3 ? parts.slice(-3).join(sep) : parts.join(sep);
|
|
842
|
-
})(file, rootPath)).join(', ');
|
|
861
|
+
let fileInfo = files.slice(0, 1).map((file)=>{
|
|
862
|
+
let prefix, filePath, parts;
|
|
863
|
+
return prefix = rootPath.endsWith(sep) ? rootPath : rootPath + sep, (filePath = file).startsWith(prefix) && (filePath = filePath.slice(prefix.length)), (parts = filePath.split(sep).filter(Boolean)).length > 3 ? parts.slice(-3).join(sep) : parts.join(sep);
|
|
864
|
+
}).join(', ');
|
|
843
865
|
return files.length > 1 ? `${fileInfo} and ${files.length - 1} more` : fileInfo;
|
|
844
866
|
}
|
|
845
|
-
|
|
846
|
-
let changedFiles = compiler.modifiedFiles ? Array.from(compiler.modifiedFiles) : null;
|
|
847
|
-
if (null == changedFiles ? void 0 : changedFiles.length) {
|
|
848
|
-
let fileInfo = formatFileList(changedFiles, root);
|
|
849
|
-
logger_logger.wait(`building ${colors.dim(fileInfo)}`);
|
|
850
|
-
return;
|
|
851
|
-
}
|
|
852
|
-
let removedFiles = compiler.removedFiles ? Array.from(compiler.removedFiles) : null;
|
|
853
|
-
if (null == removedFiles ? void 0 : removedFiles.length) {
|
|
854
|
-
let fileInfo = formatFileList(removedFiles, root);
|
|
855
|
-
logger_logger.wait(`building ${colors.dim(`removed ${fileInfo}`)}`);
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
logger_logger.wait('building...');
|
|
859
|
-
}
|
|
867
|
+
let sameCount = 0;
|
|
860
868
|
async function compileDone(compiler, stats) {
|
|
861
869
|
let compileTime = stats.toJson({
|
|
862
870
|
preset: 'errors-only',
|
|
@@ -867,27 +875,35 @@ async function compileDone(compiler, stats) {
|
|
|
867
875
|
stats
|
|
868
876
|
}), logger_logger.ready(colors.green(`built in ${prettyTime(compileTime)}`));
|
|
869
877
|
else {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
878
|
+
let fileInfo = function(changedFiles, removedFiles, root) {
|
|
879
|
+
if (!(null == changedFiles ? void 0 : changedFiles.length) && !(null == removedFiles ? void 0 : removedFiles.length)) return null;
|
|
880
|
+
if ((null == changedFiles ? void 0 : changedFiles.length) && (null == removedFiles ? void 0 : removedFiles.length)) {
|
|
881
|
+
let changedInfo = formatFileList(changedFiles, root), removedInfo = formatFileList(removedFiles, root);
|
|
882
|
+
return `${changedInfo}, removed ${removedInfo}`;
|
|
883
|
+
}
|
|
884
|
+
return (null == changedFiles ? void 0 : changedFiles.length) ? formatFileList(changedFiles, root) : (null == removedFiles ? void 0 : removedFiles.length) ? `removed ${formatFileList(removedFiles, root)}` : null;
|
|
885
|
+
}(compiler.modifiedFiles ? Array.from(compiler.modifiedFiles) : null, compiler.removedFiles ? Array.from(compiler.removedFiles) : null, root);
|
|
886
|
+
if (!fileInfo) return;
|
|
887
|
+
if (fileInfo === lastFileInfo ? sameCount++ : (lastFileInfo = fileInfo, sameCount = 1), isDebug()) {
|
|
888
|
+
var modules;
|
|
889
|
+
let nodeModulesStats, nodeModulesPath;
|
|
890
|
+
Object.entries((modules = stats.compilation.modules, nodeModulesStats = {}, nodeModulesPath = node_path.resolve(root, 'node_modules'), modules.forEach((module)=>{
|
|
873
891
|
let { resource } = module;
|
|
874
892
|
if (null == resource ? void 0 : resource.includes(nodeModulesPath)) {
|
|
875
893
|
let packageName, pathParts = node_path.relative(nodeModulesPath, resource).split(sep);
|
|
876
|
-
(packageName = '.pnpm' === pathParts[0] && pathParts.length >= 4 ? pathParts[3].startsWith('@') ? `${pathParts[3]}/${pathParts[4]}` : pathParts[3] : pathParts[0].startsWith('@') ? `${pathParts[0]}/${pathParts[1]}` : pathParts[0]) && nodeModulesStats
|
|
894
|
+
(packageName = '.pnpm' === pathParts[0] && pathParts.length >= 4 ? pathParts[3].startsWith('@') ? `${pathParts[3]}/${pathParts[4]}` : pathParts[3] : pathParts[0].startsWith('@') ? `${pathParts[0]}/${pathParts[1]}` : pathParts[0]) && (nodeModulesStats[packageName] = (nodeModulesStats[packageName] || 0) + 1);
|
|
877
895
|
}
|
|
878
|
-
}), nodeModulesStats
|
|
896
|
+
}), nodeModulesStats)).sort((a, b)=>a[1] - b[1]).forEach(([packageName, count])=>{
|
|
879
897
|
logger_logger.debug(`${colors.cyan(packageName)}: ${colors.yellow(count)} modules`);
|
|
880
898
|
});
|
|
881
899
|
}
|
|
882
|
-
logger_logger.
|
|
900
|
+
isDebug() || logger_logger.clear(), console.log(colors.dim(getTime()), colors.cyan(colors.bold(`[${global.__unpack_caller_name}]`)), colors.green(utils_isDevServer() ? 'hmr update' : 'build'), `${colors.dim(fileInfo)}${sameCount > 1 ? ` ${colors.yellow(`(x${sameCount})`)}` : ''}`, isDebug() ? colors.dim(`| ${prettyTime(compileTime)} (${stats.compilation.modules.size} modules)`) : '');
|
|
883
901
|
}
|
|
884
902
|
}
|
|
885
903
|
let progress_PLUGIN_NAME = 'ProgressPlugin';
|
|
886
904
|
class ProgressLiteRspackPlugin {
|
|
887
905
|
apply(compiler) {
|
|
888
|
-
compiler.hooks.
|
|
889
|
-
(!utils_isDevServer() || global.__unpack_dev_server_started) && printDevLog(compiler, compiler.options.context);
|
|
890
|
-
}), compiler.hooks.run.tap(progress_PLUGIN_NAME, ()=>{
|
|
906
|
+
compiler.hooks.run.tap(progress_PLUGIN_NAME, ()=>{
|
|
891
907
|
logger_logger.info('build started...');
|
|
892
908
|
}), compiler.hooks.afterDone.tap(progress_PLUGIN_NAME, async (stats)=>{
|
|
893
909
|
await compileDone(compiler, stats);
|
|
@@ -896,9 +912,7 @@ class ProgressLiteRspackPlugin {
|
|
|
896
912
|
}
|
|
897
913
|
class ProgressRspackPlugin extends rspack.ProgressPlugin {
|
|
898
914
|
apply(compiler) {
|
|
899
|
-
super.apply(compiler), compiler.hooks.
|
|
900
|
-
(!utils_isDevServer() || global.__unpack_dev_server_started) && printDevLog(compiler, compiler.options.context);
|
|
901
|
-
}), compiler.hooks.afterDone.tap(progress_PLUGIN_NAME, async (stats)=>{
|
|
915
|
+
super.apply(compiler), compiler.hooks.afterDone.tap(progress_PLUGIN_NAME, async (stats)=>{
|
|
902
916
|
await compileDone(compiler, stats);
|
|
903
917
|
});
|
|
904
918
|
}
|
|
@@ -1097,10 +1111,9 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1097
1111
|
let filePath = module.replace(/^.*!/, ''), relativePath = node_path.relative(unpackConfig.root, filePath);
|
|
1098
1112
|
return relativePath.startsWith('..') ? filePath : relativePath;
|
|
1099
1113
|
}).slice(0, -1);
|
|
1100
|
-
if (2 + uniquePaths.join(
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
uniquePaths.forEach((p, i)=>{
|
|
1114
|
+
if (2 + uniquePaths.join(' → ').length > (process.stdout.columns || 80)) {
|
|
1115
|
+
let arrow, lastIndex;
|
|
1116
|
+
console.log(''), arrow = '↳ ', lastIndex = uniquePaths.length - 1, uniquePaths.forEach((p, i)=>{
|
|
1104
1117
|
switch(i){
|
|
1105
1118
|
case 0:
|
|
1106
1119
|
console.log(` ${p}`);
|
|
@@ -1113,12 +1126,10 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1113
1126
|
}
|
|
1114
1127
|
}), console.log(` ${arrow}${uniquePaths[0]}`), console.log('');
|
|
1115
1128
|
} else {
|
|
1116
|
-
let line1
|
|
1117
|
-
uniquePaths.forEach((p, i)=>{
|
|
1118
|
-
line1 += p, i < uniquePaths.length - 1 ? line1 +=
|
|
1119
|
-
});
|
|
1120
|
-
let lineLength = downArrowPos - 2;
|
|
1121
|
-
console.log(''), console.log(line1), console.log(' ' + ' '.repeat(0) + "\u2191" + ' '.repeat(downArrowPos - 2 - 1) + "\u2193"), console.log(' ' + ' '.repeat(0) + "\u2514" + "\u2500".repeat(lineLength - 1) + "\u2518"), console.log('');
|
|
1129
|
+
let line1, downArrowPos, lineLength;
|
|
1130
|
+
line1 = ' ', downArrowPos = 0, uniquePaths.forEach((p, i)=>{
|
|
1131
|
+
line1 += p, i < uniquePaths.length - 1 ? line1 += ' → ' : downArrowPos = line1.length - 1;
|
|
1132
|
+
}), lineLength = downArrowPos - 2, console.log(''), console.log(line1), console.log(' ' + ' '.repeat(0) + '↑' + ' '.repeat(downArrowPos - 2 - 1) + '↓'), console.log(' ' + ' '.repeat(0) + '└' + '─'.repeat(lineLength - 1) + '┘'), console.log('');
|
|
1122
1133
|
}
|
|
1123
1134
|
},
|
|
1124
1135
|
onEnd () {
|
|
@@ -1161,9 +1172,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1161
1172
|
experiments: {
|
|
1162
1173
|
css: !1,
|
|
1163
1174
|
asyncWebAssembly: !0,
|
|
1164
|
-
lazyBarrel: !0
|
|
1165
|
-
inlineEnum: !0,
|
|
1166
|
-
typeReexportsPresence: !0
|
|
1175
|
+
lazyBarrel: !0
|
|
1167
1176
|
},
|
|
1168
1177
|
optimization: {
|
|
1169
1178
|
moduleIds: isDev() ? 'named' : 'deterministic',
|
|
@@ -1234,7 +1243,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1234
1243
|
'parser',
|
|
1235
1244
|
'css/module'
|
|
1236
1245
|
], {
|
|
1237
|
-
namedExports:
|
|
1246
|
+
namedExports: !1
|
|
1238
1247
|
}), setValueByPath(config, [
|
|
1239
1248
|
'module',
|
|
1240
1249
|
'generator',
|
|
@@ -1387,7 +1396,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1387
1396
|
})(),
|
|
1388
1397
|
localIdentName: !1 !== modules && (modules.localIdentName || CSS_MODULES_LOCAL_IDENT_NAME),
|
|
1389
1398
|
exportLocalsConvention: EXPORT_LOCALS_CONVENTION,
|
|
1390
|
-
namedExport:
|
|
1399
|
+
namedExport: !1
|
|
1391
1400
|
},
|
|
1392
1401
|
sourceMap
|
|
1393
1402
|
}
|
|
@@ -1503,7 +1512,6 @@ async function unpackBuild(unpackConfig) {
|
|
|
1503
1512
|
};
|
|
1504
1513
|
isWatch() ? compiler.watch({}, handler) : compiler.run(handler);
|
|
1505
1514
|
}
|
|
1506
|
-
let restartCleaners = [];
|
|
1507
1515
|
var openBrowser_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
1508
1516
|
async function openBrowser(url) {
|
|
1509
1517
|
if ('darwin' === process.platform) try {
|
|
@@ -1572,19 +1580,20 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1572
1580
|
'react-dom': 'ReactDOM',
|
|
1573
1581
|
'react-router-dom': 'ReactRouterDOM'
|
|
1574
1582
|
})[pkgName] || pkgName, getExternalValue = (pkgName)=>`window ${getExternalLibraryName(pkgName)}`, prebundleDeps = async ({ unpackConfig })=>{
|
|
1575
|
-
var _unpackConfig_dev;
|
|
1576
|
-
let count = {
|
|
1583
|
+
var _unpackConfig_dev, externals;
|
|
1584
|
+
let existExternals, cacheDir, count = {
|
|
1577
1585
|
total: 0,
|
|
1578
1586
|
bundled: 0
|
|
1579
1587
|
}, failedDeps = [], root = unpackConfig.root, failedDepsCachePath = node_path.resolve(root, TEMP_DIR, 'failed-deps.json'), failedCache = node_fs.existsSync(failedDepsCachePath) ? JSON.parse(node_fs.readFileSync(failedDepsCachePath, 'utf-8')) : {}, updateProgress = ()=>{
|
|
1580
|
-
logUpdate(`${colors.magenta(
|
|
1588
|
+
logUpdate(`${colors.magenta('»')} optimizing dependencies (${count.bundled}/${count.total})`), count.total === count.bundled + failedDeps.length && console.log();
|
|
1581
1589
|
}, userOptions = isPlainObject(null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.prebundle) ? unpackConfig.dev.prebundle : {}, ignoreCSSDeps = userOptions.ignoreCSS || [], packageJson = JSON.parse(node_fs.readFileSync(node_path.resolve(root, 'package.json'), 'utf-8')), excludeDeps = [
|
|
1582
|
-
...((externals)=>{
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1590
|
+
...(externals = unpackConfig.externals, existExternals = new Set(), Array.isArray(externals) ? externals.forEach((item)=>{
|
|
1591
|
+
isPlainObject(item) && Object.keys(item).forEach((key)=>{
|
|
1592
|
+
existExternals.add(key);
|
|
1593
|
+
});
|
|
1594
|
+
}) : isPlainObject(externals) && Object.keys(externals).forEach((key)=>{
|
|
1595
|
+
existExternals.add(key);
|
|
1596
|
+
}), Array.from(existExternals) || []),
|
|
1588
1597
|
...userOptions.exclude || []
|
|
1589
1598
|
], shouldIncludeDeps = Object.keys(packageJson.dependencies).filter((pkgName)=>!excludeDeps.includes(pkgName)), noEntryDeps = [], needBundleDeps = shouldIncludeDeps.map((pkgName)=>{
|
|
1590
1599
|
let packageJson = JSON.parse(node_fs.readFileSync(node_path.resolve(root, 'node_modules', pkgName, 'package.json'), 'utf-8')), version = packageJson.version;
|
|
@@ -1730,17 +1739,17 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1730
1739
|
resolve(isFailed ? void 0 : getResult());
|
|
1731
1740
|
});
|
|
1732
1741
|
});
|
|
1733
|
-
}))(depInfo)))
|
|
1734
|
-
node_fs.existsSync(cacheDir) || node_fs.mkdirSync(cacheDir, {
|
|
1742
|
+
}))(depInfo)));
|
|
1743
|
+
cacheDir = node_path.dirname(failedDepsCachePath), node_fs.existsSync(cacheDir) || node_fs.mkdirSync(cacheDir, {
|
|
1735
1744
|
recursive: !0
|
|
1736
1745
|
}), node_fs.writeFileSync(failedDepsCachePath, JSON.stringify(failedCache, null, 2), 'utf-8'), failedDeps[0] && logger_logger.warn(`something went wrong while optimizing "${colors.bold(failedDeps.join(', '))}"`);
|
|
1737
1746
|
let cachePath = node_path.resolve(root, TEMP_DIR, 'umd'), app = express();
|
|
1738
1747
|
app.use(cors()), app.use("/umd", express.static(cachePath));
|
|
1739
1748
|
let port = await getPort(), staticServer = app.listen(port, ()=>{});
|
|
1740
|
-
|
|
1741
|
-
let
|
|
1749
|
+
addRestartCleaner(()=>new Promise((resolve)=>staticServer.close(()=>resolve())));
|
|
1750
|
+
let externals1 = {}, jsAssets = [], cssAssets = [], preJsAssets = [];
|
|
1742
1751
|
return bundledDeps.filter(Boolean).forEach((dep)=>{
|
|
1743
|
-
dep && (
|
|
1752
|
+
dep && (externals1[dep.name] = getExternalValue(dep.name), dep.assets.forEach((absPath)=>{
|
|
1744
1753
|
let relativePath = node_path.relative(cachePath, absPath), preDeps = [
|
|
1745
1754
|
'react',
|
|
1746
1755
|
'react-dom',
|
|
@@ -1758,10 +1767,10 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1758
1767
|
}
|
|
1759
1768
|
}));
|
|
1760
1769
|
}), unpackConfig.externals = Array.isArray(unpackConfig.externals) ? [
|
|
1761
|
-
|
|
1770
|
+
externals1,
|
|
1762
1771
|
...unpackConfig.externals
|
|
1763
1772
|
] : {
|
|
1764
|
-
...
|
|
1773
|
+
...externals1,
|
|
1765
1774
|
...unpackConfig.externals
|
|
1766
1775
|
}, unpackConfig.plugins.push({
|
|
1767
1776
|
name: 'unpack:prebundle',
|
|
@@ -1786,7 +1795,7 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1786
1795
|
}), unpackConfig;
|
|
1787
1796
|
};
|
|
1788
1797
|
async function unpackDev(originalUnpackConfig) {
|
|
1789
|
-
var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1, _unpackConfig_server2;
|
|
1798
|
+
var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1, _unpackConfig_server2, _unpackConfig_server3;
|
|
1790
1799
|
let unpackConfig = originalUnpackConfig;
|
|
1791
1800
|
(null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.prebundle) && (unpackConfig = await prebundleDeps({
|
|
1792
1801
|
unpackConfig
|
|
@@ -1821,67 +1830,90 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1821
1830
|
var _req_headers_accept;
|
|
1822
1831
|
(null == (_req_headers_accept = req.headers.accept) ? void 0 : _req_headers_accept.includes('html')) && (req.url = '/index.html'), next();
|
|
1823
1832
|
}), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1824
|
-
let server = new
|
|
1825
|
-
await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.
|
|
1826
|
-
|
|
1827
|
-
|
|
1833
|
+
let server = new RspackDevServer(devServerOptions, compiler);
|
|
1834
|
+
await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.3.1`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - global.__unpack_start_time))} ms\n`), printAddressUrls(port, null == (_unpackConfig_server2 = unpackConfig.server) ? void 0 : _unpackConfig_server2.host), addRestartCleaner(()=>server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())));
|
|
1835
|
+
let open = null == (_unpackConfig_server3 = unpackConfig.server) ? void 0 : _unpackConfig_server3.open, url = isString(open) ? open : `http://localhost:${port}`;
|
|
1836
|
+
open && openBrowser(url), setupCliShortcuts({
|
|
1837
|
+
openPage: async ()=>{
|
|
1838
|
+
await openBrowser(url);
|
|
1839
|
+
},
|
|
1840
|
+
closeServer: async ()=>{
|
|
1841
|
+
await cleanUpBeforeRestart(), process.exit(0);
|
|
1842
|
+
},
|
|
1843
|
+
printUrls: ()=>{
|
|
1844
|
+
var _unpackConfig_server;
|
|
1845
|
+
printAddressUrls(port, null == (_unpackConfig_server = unpackConfig.server) ? void 0 : _unpackConfig_server.host);
|
|
1846
|
+
},
|
|
1847
|
+
restartServer: async ()=>{
|
|
1848
|
+
logger_logger.clear(), await cleanUpBeforeRestart(), createUnpack({
|
|
1849
|
+
cwd: currentDevUnpackConfig.root,
|
|
1850
|
+
config: currentDevUnpackConfig
|
|
1851
|
+
}).dev();
|
|
1852
|
+
}
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
function printAddressUrls(port, host) {
|
|
1856
|
+
let addressUrls = getAddressUrls({
|
|
1857
|
+
port
|
|
1858
|
+
}), colorPrefix = colors.green('➜');
|
|
1859
|
+
addressUrls.forEach((addr, index)=>{
|
|
1828
1860
|
let url;
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1861
|
+
if (!host && 0 !== index) {
|
|
1862
|
+
1 === index && console.log(` ${colors.dim(colorPrefix)} ${colors.bold(colors.dim('Network:'))} ${colors.dim('use')} ${colors.bold('--host')} ${colors.dim('to expose')}`);
|
|
1863
|
+
return;
|
|
1864
|
+
}
|
|
1865
|
+
console.log(` ${colorPrefix} ${colors.bold(addr.label)}${(url = addr.url, colors.cyan(url.replace(/:(\d+)\//, (_, port)=>`:${colors.bold(port)}/`)))}`);
|
|
1832
1866
|
});
|
|
1833
|
-
let open = null == (_unpackConfig_server2 = unpackConfig.server) ? void 0 : _unpackConfig_server2.open;
|
|
1834
|
-
if (open) {
|
|
1835
|
-
let url = isString(open) ? open : `http://localhost:${port}`;
|
|
1836
|
-
await openBrowser(url);
|
|
1837
|
-
}
|
|
1838
1867
|
}
|
|
1839
1868
|
function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
1840
|
-
let resolveConfig = ()=>
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1869
|
+
let resolveConfig = ()=>{
|
|
1870
|
+
let defaultConfig = {
|
|
1871
|
+
root: cwd,
|
|
1872
|
+
build: {
|
|
1873
|
+
outDir: 'dist',
|
|
1874
|
+
minify: isProd(),
|
|
1875
|
+
sourceMap: !isProd() && 'cheap-module-source-map',
|
|
1876
|
+
parallel: !0,
|
|
1877
|
+
filenameHash: !0,
|
|
1878
|
+
target: 'es2022'
|
|
1879
|
+
},
|
|
1880
|
+
dev: {
|
|
1881
|
+
lazyCompilation: !0
|
|
1882
|
+
},
|
|
1883
|
+
server: {
|
|
1884
|
+
port: 3000
|
|
1885
|
+
},
|
|
1886
|
+
html: {
|
|
1887
|
+
mountId: 'root'
|
|
1888
|
+
},
|
|
1889
|
+
css: {
|
|
1890
|
+
modules: !0,
|
|
1891
|
+
transformer: 'postcss',
|
|
1892
|
+
sourceMap: !1
|
|
1893
|
+
},
|
|
1894
|
+
performance: {
|
|
1895
|
+
chunkSplit: {
|
|
1896
|
+
strategy: 'split-by-experience'
|
|
1897
|
+
}
|
|
1898
|
+
},
|
|
1899
|
+
typeCheck: !0,
|
|
1900
|
+
envPrefix: [
|
|
1901
|
+
'PUBLIC_'
|
|
1902
|
+
]
|
|
1903
|
+
};
|
|
1904
|
+
return global.__unpack_caller_name = callerName, {
|
|
1905
|
+
...mergeConfig(defaultConfig, config),
|
|
1875
1906
|
_context: {
|
|
1876
1907
|
callerName,
|
|
1877
|
-
version: "3.
|
|
1908
|
+
version: "3.3.1"
|
|
1878
1909
|
}
|
|
1879
|
-
}
|
|
1910
|
+
};
|
|
1911
|
+
};
|
|
1880
1912
|
return {
|
|
1881
1913
|
build: async ({ watch } = {})=>{
|
|
1882
1914
|
setNodeEnv(watch ? 'development' : 'production');
|
|
1883
1915
|
let config = resolveConfig();
|
|
1884
|
-
console.log(colors.rainbow(`${callerName} v3.
|
|
1916
|
+
console.log(colors.rainbow(`${callerName} v3.3.1`), colors.green(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
|
|
1885
1917
|
},
|
|
1886
1918
|
dev: async ()=>{
|
|
1887
1919
|
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
|
|
@@ -1903,4 +1935,5 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
|
|
|
1903
1935
|
...options
|
|
1904
1936
|
});
|
|
1905
1937
|
}
|
|
1906
|
-
|
|
1938
|
+
var __webpack_exports__CSS_NAMED_EXPORT = !1;
|
|
1939
|
+
export { CSS_MODULES_LOCAL_IDENT_NAME, CSS_MODULES_REGEX, DEFAULT_DEV_HOST, DEV_DEFAULT_FILENAME, EXPORT_LOCALS_CONVENTION, logger_LogColor as LogColor, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, TEMPLATE_CONTENT, TEMP_DIR, THREAD_OPTIONS, addRestartCleaner, cleanUpBeforeRestart, clearLine, colors, createChokidar, createUnpack, currentDevUnpackConfig, debounce, defineConfig, esVersionToBrowserslist, findExists, getAddressUrls, getCompiledPkgPath, getIpv4Interfaces, getNodeEnv, getPathInJs, getPort, getTime, getUserDepPath, getUserDepVersion, getValueByPath, isBoolean, isCI, isCSSModules, isDebug, isDev, utils_isDevServer as isDevServer, isEmptyDir, isFileExists, isFileSync, isFunction, isNodeVersionAtLeast, isObject, isPlainObject, isProd, isRegExp, isString, isUndefined, isWatch, isWin, loadConfig, logUpdate, logger_logger as logger, mergeConfig, pathExists, prettyTime, removeDir, resolveConfigPath, rspack, setCurrentDevUnpackConfig, setDevServer, setNodeEnv, setValueByPath, setupCliShortcuts, trackPerformance, __webpack_exports__CSS_NAMED_EXPORT as CSS_NAMED_EXPORT };
|