@unpackjs/core 3.2.6 → 3.3.0
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 +90 -79
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/sass-loader/index.js +8 -8
- package/dist/index.cjs +265 -190
- package/dist/index.js +260 -195
- package/dist/typedCssModulesLoader.mjs +5 -13
- package/dist-types/bundler-config/index.d.ts.map +1 -1
- package/dist-types/bundler-config/plugins/jsMinify.d.ts +1 -1
- package/dist-types/bundler-config/plugins/jsMinify.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/types/oxc.d.ts +2 -2
- package/dist-types/types/oxc.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,26 +7,25 @@ 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";
|
|
20
21
|
import { glob, globSync } from "tinyglobby";
|
|
21
22
|
import typed_css_modules from "typed-css-modules";
|
|
22
|
-
import { minify } from "oxc-minify";
|
|
23
23
|
import { exec, spawn } from "node:child_process";
|
|
24
24
|
import { promisify } from "node:util";
|
|
25
25
|
import node_zlib from "node:zlib";
|
|
26
|
+
import { RspackDevServer } from "@rspack/dev-server";
|
|
26
27
|
import cors from "cors";
|
|
27
28
|
import express from "express";
|
|
28
|
-
import webpack_dev_server from "webpack-dev-server";
|
|
29
29
|
import chokidar from "chokidar";
|
|
30
30
|
var LogColor, __webpack_modules__ = {
|
|
31
31
|
"compiled/webpack-bundle-analyzer": function(module) {
|
|
@@ -52,8 +52,14 @@ let colors = {
|
|
|
52
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`;
|
|
53
53
|
return output;
|
|
54
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;
|
|
55
61
|
};
|
|
56
|
-
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);
|
|
57
63
|
let CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]', CSS_MODULES_REGEX = /\.module\.\w+$/i, DEV_DEFAULT_FILENAME = {
|
|
58
64
|
js: 'js/[name].js',
|
|
59
65
|
jsAsync: 'js/async/[name].js',
|
|
@@ -64,7 +70,7 @@ let CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]', CSS_MODULE
|
|
|
64
70
|
jsAsync: 'js/async/[name].[contenthash:8].js',
|
|
65
71
|
css: 'css/[name].[contenthash:8].css',
|
|
66
72
|
cssAsync: 'css/async/[name].[contenthash:8].css'
|
|
67
|
-
}, 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 = {
|
|
68
74
|
workers: 2
|
|
69
75
|
}, DEFAULT_DEV_HOST = '0.0.0.0', TEMPLATE_CONTENT = ({ title = '', headTag = '', mountId = '' })=>`<!DOCTYPE html>
|
|
70
76
|
<html lang="en">
|
|
@@ -178,12 +184,11 @@ let debounce = (fn, delay)=>{
|
|
|
178
184
|
});
|
|
179
185
|
return addressUrls;
|
|
180
186
|
}, trackPerformance = (msg)=>{
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
global[k] = performance.now();
|
|
187
|
+
if (!lastTrackTime) {
|
|
188
|
+
lastTrackTime = performance.now();
|
|
184
189
|
return;
|
|
185
190
|
}
|
|
186
|
-
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();
|
|
187
192
|
}, getPathInJs = (absPath)=>JSON.stringify(absPath).slice(1, -1), mergeConfig = merge, getUserDepVersion = (root, dep)=>{
|
|
188
193
|
let depPath = getUserDepPath(root, dep);
|
|
189
194
|
if (depPath) return JSON.parse(node_fs.readFileSync(node_path.resolve(depPath, 'package.json'), 'utf-8')).version;
|
|
@@ -224,50 +229,98 @@ let isCSSModules = ({ resourcePath, modules })=>{
|
|
|
224
229
|
if (!browsers) throw Error(`Unsupported ES version: ${esVersion}`);
|
|
225
230
|
return browsers;
|
|
226
231
|
}, logger_prefixes = {
|
|
227
|
-
wait:
|
|
228
|
-
error:
|
|
229
|
-
warn:
|
|
230
|
-
info:
|
|
231
|
-
ready:
|
|
232
|
-
event:
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
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);
|
|
244
270
|
};
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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);
|
|
265
304
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
})
|
|
270
|
-
})(
|
|
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
|
+
}
|
|
271
324
|
var config_filename = __webpack_fileURLToPath__(import.meta.url);
|
|
272
325
|
async function loadConfig({ cliOptions, command }) {
|
|
273
326
|
'build' === command ? setNodeEnv((null == cliOptions ? void 0 : cliOptions.watch) ? 'development' : 'production') : (setNodeEnv('development'), setDevServer(!0));
|
|
@@ -318,7 +371,10 @@ async function loadConfig({ cliOptions, command }) {
|
|
|
318
371
|
'bundleAnalyze'
|
|
319
372
|
], cliOptions.analyze), (null == cliOptions ? void 0 : cliOptions.root) && setValueByPath(configExport, [
|
|
320
373
|
'root'
|
|
321
|
-
], root), configExport
|
|
374
|
+
], root), (null == cliOptions ? void 0 : cliOptions.host) && setValueByPath(configExport, [
|
|
375
|
+
'server',
|
|
376
|
+
'host'
|
|
377
|
+
], cliOptions.host), configExport;
|
|
322
378
|
}
|
|
323
379
|
function defineConfig(config) {
|
|
324
380
|
return config;
|
|
@@ -572,7 +628,7 @@ class TypedCssModulesPlugin {
|
|
|
572
628
|
constructor(options){
|
|
573
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({
|
|
574
630
|
camelCase: !0,
|
|
575
|
-
namedExports:
|
|
631
|
+
namedExports: !1
|
|
576
632
|
});
|
|
577
633
|
}
|
|
578
634
|
}
|
|
@@ -589,11 +645,11 @@ class JsMinifyPlugin {
|
|
|
589
645
|
apply(compiler) {
|
|
590
646
|
let meta = JSON.stringify({
|
|
591
647
|
name: jsMinify_PLUGIN_NAME,
|
|
592
|
-
version: "3.
|
|
648
|
+
version: "3.3.0",
|
|
593
649
|
options: this.minifyOptions
|
|
594
650
|
});
|
|
595
651
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
596
|
-
compilation.hooks.chunkHash.tap(jsMinify_PLUGIN_NAME, (_, hash)=>hash.update(Buffer.from(meta))), compilation.hooks.processAssets.
|
|
652
|
+
compilation.hooks.chunkHash.tap(jsMinify_PLUGIN_NAME, (_, hash)=>hash.update(Buffer.from(meta))), compilation.hooks.processAssets.tapPromise({
|
|
597
653
|
name: jsMinify_PLUGIN_NAME,
|
|
598
654
|
stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
|
599
655
|
}, ()=>this.transformAssets(compilation)), compilation.hooks.statsPrinter.tap(jsMinify_PLUGIN_NAME, (stats)=>{
|
|
@@ -601,10 +657,10 @@ class JsMinifyPlugin {
|
|
|
601
657
|
});
|
|
602
658
|
});
|
|
603
659
|
}
|
|
604
|
-
transformAssets(compilation) {
|
|
605
|
-
let { options: { devtool } } = compilation.compiler, sourceMap = 'string' == typeof devtool && devtool.includes('source-map');
|
|
606
|
-
|
|
607
|
-
let { source, map } = asset.source.sourceAndMap(), { name } = asset, output =
|
|
660
|
+
async transformAssets(compilation) {
|
|
661
|
+
let { options: { devtool } } = compilation.compiler, sourceMap = 'string' == typeof devtool && devtool.includes('source-map'), assets = compilation.getAssets().filter((asset)=>!asset.info.minimized && isJsFile.test(asset.name)), minifyFn = this.customMinify ?? (await import("oxc-minify")).minify;
|
|
662
|
+
assets.forEach((asset)=>{
|
|
663
|
+
let { source, map } = asset.source.sourceAndMap(), { name } = asset, output = minifyFn(name, Buffer.isBuffer(source) ? source.toString() : source, {
|
|
608
664
|
sourcemap: sourceMap,
|
|
609
665
|
...this.minifyOptions
|
|
610
666
|
}), newMap = null;
|
|
@@ -619,9 +675,9 @@ class JsMinifyPlugin {
|
|
|
619
675
|
});
|
|
620
676
|
}
|
|
621
677
|
constructor(options = {}){
|
|
622
|
-
jsMinify_define_property(this, "
|
|
678
|
+
jsMinify_define_property(this, "minifyOptions", void 0), jsMinify_define_property(this, "customMinify", void 0);
|
|
623
679
|
let { implementation, ...minifyOptions } = options;
|
|
624
|
-
this.
|
|
680
|
+
this.customMinify = null == implementation ? void 0 : implementation.minify, this.minifyOptions = minifyOptions;
|
|
625
681
|
}
|
|
626
682
|
}
|
|
627
683
|
var oxlint_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
@@ -720,17 +776,17 @@ class LoadingAnimation {
|
|
|
720
776
|
}
|
|
721
777
|
constructor(){
|
|
722
778
|
loadingAnimation_define_property(this, "chars", [
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
]), loadingAnimation_define_property(this, "currentIndex", 0), loadingAnimation_define_property(this, "lastUpdateTime", 0), loadingAnimation_define_property(this, "interval",
|
|
779
|
+
'⠋',
|
|
780
|
+
'⠙',
|
|
781
|
+
'⠹',
|
|
782
|
+
'⠸',
|
|
783
|
+
'⠼',
|
|
784
|
+
'⠴',
|
|
785
|
+
'⠦',
|
|
786
|
+
'⠧',
|
|
787
|
+
'⠇',
|
|
788
|
+
'⠏'
|
|
789
|
+
]), loadingAnimation_define_property(this, "currentIndex", 0), loadingAnimation_define_property(this, "lastUpdateTime", 0), loadingAnimation_define_property(this, "interval", 100);
|
|
734
790
|
}
|
|
735
791
|
}
|
|
736
792
|
function progressBar_define_property(obj, key, value) {
|
|
@@ -795,7 +851,7 @@ async function printFileSize({ root, stats }) {
|
|
|
795
851
|
}), longest = 0, totalSize = 0, totalCompressedSize = 0;
|
|
796
852
|
await Promise.all(origin.assets.map(async (asset)=>{
|
|
797
853
|
let content = await node_fs.promises.readFile(node_path.join(distPath, asset.name)), size = content.length, compressedSize = await getCompressedSize(content);
|
|
798
|
-
totalSize += size, totalCompressedSize += compressedSize, compressedCount++, logUpdate(`${loadingAnimation.getCurrentChar()} computing gzip size (${compressedCount})...`), compressedCount === origin.assets.length && (logUpdate(
|
|
854
|
+
totalSize += size, totalCompressedSize += compressedSize, compressedCount++, logUpdate(`${loadingAnimation.getCurrentChar()} computing gzip size (${compressedCount})...`), compressedCount === origin.assets.length && (logUpdate(`✓ computed gzip size (${compressedCount})`), console.log());
|
|
799
855
|
let chunk = {
|
|
800
856
|
name: node_path.basename(asset.name),
|
|
801
857
|
path: `${distFolder}/${asset.name}`,
|
|
@@ -821,11 +877,11 @@ async function printFileSize({ root, stats }) {
|
|
|
821
877
|
chunkGroups.forEach((group)=>{
|
|
822
878
|
group.chunks.sort((a, b)=>a.size - b.size).forEach((chunk)=>{
|
|
823
879
|
let isLarge = 'JS' === group.type && chunk.size / 1000 > 500, relativeOutDir = node_path.dirname(chunk.path) + '/', log = colors.dim(relativeOutDir);
|
|
824
|
-
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(`
|
|
880
|
+
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);
|
|
825
881
|
});
|
|
826
882
|
});
|
|
827
883
|
let log = colors.blue('Total'.padEnd(longest + 2));
|
|
828
|
-
log += colors.blue(displaySize(totalSize)), console.log(log += colors.dim(`
|
|
884
|
+
log += colors.blue(displaySize(totalSize)), console.log(log += colors.dim(` │ gzip: ${displaySize(totalCompressedSize)}`));
|
|
829
885
|
}
|
|
830
886
|
function isLikelyFile(filePath) {
|
|
831
887
|
return (filePath.split(sep).pop() || '').includes('.');
|
|
@@ -835,29 +891,13 @@ function formatFileList(paths, rootPath) {
|
|
|
835
891
|
0 === files.length && (files = [
|
|
836
892
|
paths[0]
|
|
837
893
|
]);
|
|
838
|
-
let fileInfo = files.slice(0, 1).map((file)=>
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
return parts.length > 3 ? parts.slice(-3).join(sep) : parts.join(sep);
|
|
843
|
-
})(file, rootPath)).join(', ');
|
|
894
|
+
let fileInfo = files.slice(0, 1).map((file)=>{
|
|
895
|
+
let prefix, filePath, parts;
|
|
896
|
+
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);
|
|
897
|
+
}).join(', ');
|
|
844
898
|
return files.length > 1 ? `${fileInfo} and ${files.length - 1} more` : fileInfo;
|
|
845
899
|
}
|
|
846
|
-
|
|
847
|
-
let changedFiles = compiler.modifiedFiles ? Array.from(compiler.modifiedFiles) : null;
|
|
848
|
-
if (null == changedFiles ? void 0 : changedFiles.length) {
|
|
849
|
-
let fileInfo = formatFileList(changedFiles, root);
|
|
850
|
-
logger_logger.wait(`building ${colors.dim(fileInfo)}`);
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
let removedFiles = compiler.removedFiles ? Array.from(compiler.removedFiles) : null;
|
|
854
|
-
if (null == removedFiles ? void 0 : removedFiles.length) {
|
|
855
|
-
let fileInfo = formatFileList(removedFiles, root);
|
|
856
|
-
logger_logger.wait(`building ${colors.dim(`removed ${fileInfo}`)}`);
|
|
857
|
-
return;
|
|
858
|
-
}
|
|
859
|
-
logger_logger.wait('building...');
|
|
860
|
-
}
|
|
900
|
+
let sameCount = 0;
|
|
861
901
|
async function compileDone(compiler, stats) {
|
|
862
902
|
let compileTime = stats.toJson({
|
|
863
903
|
preset: 'errors-only',
|
|
@@ -868,27 +908,35 @@ async function compileDone(compiler, stats) {
|
|
|
868
908
|
stats
|
|
869
909
|
}), logger_logger.ready(colors.green(`built in ${prettyTime(compileTime)}`));
|
|
870
910
|
else {
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
911
|
+
let fileInfo = function(changedFiles, removedFiles, root) {
|
|
912
|
+
if (!(null == changedFiles ? void 0 : changedFiles.length) && !(null == removedFiles ? void 0 : removedFiles.length)) return null;
|
|
913
|
+
if ((null == changedFiles ? void 0 : changedFiles.length) && (null == removedFiles ? void 0 : removedFiles.length)) {
|
|
914
|
+
let changedInfo = formatFileList(changedFiles, root), removedInfo = formatFileList(removedFiles, root);
|
|
915
|
+
return `${changedInfo}, removed ${removedInfo}`;
|
|
916
|
+
}
|
|
917
|
+
return (null == changedFiles ? void 0 : changedFiles.length) ? formatFileList(changedFiles, root) : (null == removedFiles ? void 0 : removedFiles.length) ? `removed ${formatFileList(removedFiles, root)}` : null;
|
|
918
|
+
}(compiler.modifiedFiles ? Array.from(compiler.modifiedFiles) : null, compiler.removedFiles ? Array.from(compiler.removedFiles) : null, root);
|
|
919
|
+
if (!fileInfo) return;
|
|
920
|
+
if (fileInfo === lastFileInfo ? sameCount++ : (lastFileInfo = fileInfo, sameCount = 1), isDebug()) {
|
|
921
|
+
var modules;
|
|
922
|
+
let nodeModulesStats, nodeModulesPath;
|
|
923
|
+
Object.entries((modules = stats.compilation.modules, nodeModulesStats = {}, nodeModulesPath = node_path.resolve(root, 'node_modules'), modules.forEach((module)=>{
|
|
874
924
|
let { resource } = module;
|
|
875
925
|
if (null == resource ? void 0 : resource.includes(nodeModulesPath)) {
|
|
876
926
|
let packageName, pathParts = node_path.relative(nodeModulesPath, resource).split(sep);
|
|
877
|
-
(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
|
|
927
|
+
(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);
|
|
878
928
|
}
|
|
879
|
-
}), nodeModulesStats
|
|
929
|
+
}), nodeModulesStats)).sort((a, b)=>a[1] - b[1]).forEach(([packageName, count])=>{
|
|
880
930
|
logger_logger.debug(`${colors.cyan(packageName)}: ${colors.yellow(count)} modules`);
|
|
881
931
|
});
|
|
882
932
|
}
|
|
883
|
-
logger_logger.
|
|
933
|
+
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)`) : '');
|
|
884
934
|
}
|
|
885
935
|
}
|
|
886
936
|
let progress_PLUGIN_NAME = 'ProgressPlugin';
|
|
887
937
|
class ProgressLiteRspackPlugin {
|
|
888
938
|
apply(compiler) {
|
|
889
|
-
compiler.hooks.
|
|
890
|
-
(!utils_isDevServer() || global.__unpack_dev_server_started) && printDevLog(compiler, compiler.options.context);
|
|
891
|
-
}), compiler.hooks.run.tap(progress_PLUGIN_NAME, ()=>{
|
|
939
|
+
compiler.hooks.run.tap(progress_PLUGIN_NAME, ()=>{
|
|
892
940
|
logger_logger.info('build started...');
|
|
893
941
|
}), compiler.hooks.afterDone.tap(progress_PLUGIN_NAME, async (stats)=>{
|
|
894
942
|
await compileDone(compiler, stats);
|
|
@@ -897,9 +945,7 @@ class ProgressLiteRspackPlugin {
|
|
|
897
945
|
}
|
|
898
946
|
class ProgressRspackPlugin extends rspack.ProgressPlugin {
|
|
899
947
|
apply(compiler) {
|
|
900
|
-
super.apply(compiler), compiler.hooks.
|
|
901
|
-
(!utils_isDevServer() || global.__unpack_dev_server_started) && printDevLog(compiler, compiler.options.context);
|
|
902
|
-
}), compiler.hooks.afterDone.tap(progress_PLUGIN_NAME, async (stats)=>{
|
|
948
|
+
super.apply(compiler), compiler.hooks.afterDone.tap(progress_PLUGIN_NAME, async (stats)=>{
|
|
903
949
|
await compileDone(compiler, stats);
|
|
904
950
|
});
|
|
905
951
|
}
|
|
@@ -1098,10 +1144,9 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1098
1144
|
let filePath = module.replace(/^.*!/, ''), relativePath = node_path.relative(unpackConfig.root, filePath);
|
|
1099
1145
|
return relativePath.startsWith('..') ? filePath : relativePath;
|
|
1100
1146
|
}).slice(0, -1);
|
|
1101
|
-
if (2 + uniquePaths.join(
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
uniquePaths.forEach((p, i)=>{
|
|
1147
|
+
if (2 + uniquePaths.join(' → ').length > (process.stdout.columns || 80)) {
|
|
1148
|
+
let arrow, lastIndex;
|
|
1149
|
+
console.log(''), arrow = '↳ ', lastIndex = uniquePaths.length - 1, uniquePaths.forEach((p, i)=>{
|
|
1105
1150
|
switch(i){
|
|
1106
1151
|
case 0:
|
|
1107
1152
|
console.log(` ${p}`);
|
|
@@ -1114,12 +1159,10 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1114
1159
|
}
|
|
1115
1160
|
}), console.log(` ${arrow}${uniquePaths[0]}`), console.log('');
|
|
1116
1161
|
} else {
|
|
1117
|
-
let line1
|
|
1118
|
-
uniquePaths.forEach((p, i)=>{
|
|
1119
|
-
line1 += p, i < uniquePaths.length - 1 ? line1 +=
|
|
1120
|
-
});
|
|
1121
|
-
let lineLength = downArrowPos - 2;
|
|
1122
|
-
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('');
|
|
1162
|
+
let line1, downArrowPos, lineLength;
|
|
1163
|
+
line1 = ' ', downArrowPos = 0, uniquePaths.forEach((p, i)=>{
|
|
1164
|
+
line1 += p, i < uniquePaths.length - 1 ? line1 += ' → ' : downArrowPos = line1.length - 1;
|
|
1165
|
+
}), 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('');
|
|
1123
1166
|
}
|
|
1124
1167
|
},
|
|
1125
1168
|
onEnd () {
|
|
@@ -1162,9 +1205,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1162
1205
|
experiments: {
|
|
1163
1206
|
css: !1,
|
|
1164
1207
|
asyncWebAssembly: !0,
|
|
1165
|
-
lazyBarrel: !0
|
|
1166
|
-
inlineEnum: !0,
|
|
1167
|
-
typeReexportsPresence: !0
|
|
1208
|
+
lazyBarrel: !0
|
|
1168
1209
|
},
|
|
1169
1210
|
optimization: {
|
|
1170
1211
|
moduleIds: isDev() ? 'named' : 'deterministic',
|
|
@@ -1235,7 +1276,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1235
1276
|
'parser',
|
|
1236
1277
|
'css/module'
|
|
1237
1278
|
], {
|
|
1238
|
-
namedExports:
|
|
1279
|
+
namedExports: !1
|
|
1239
1280
|
}), setValueByPath(config, [
|
|
1240
1281
|
'module',
|
|
1241
1282
|
'generator',
|
|
@@ -1388,7 +1429,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1388
1429
|
})(),
|
|
1389
1430
|
localIdentName: !1 !== modules && (modules.localIdentName || CSS_MODULES_LOCAL_IDENT_NAME),
|
|
1390
1431
|
exportLocalsConvention: EXPORT_LOCALS_CONVENTION,
|
|
1391
|
-
namedExport:
|
|
1432
|
+
namedExport: !1
|
|
1392
1433
|
},
|
|
1393
1434
|
sourceMap
|
|
1394
1435
|
}
|
|
@@ -1504,7 +1545,6 @@ async function unpackBuild(unpackConfig) {
|
|
|
1504
1545
|
};
|
|
1505
1546
|
isWatch() ? compiler.watch({}, handler) : compiler.run(handler);
|
|
1506
1547
|
}
|
|
1507
|
-
let restartCleaners = [];
|
|
1508
1548
|
var openBrowser_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
1509
1549
|
async function openBrowser(url) {
|
|
1510
1550
|
if ('darwin' === process.platform) try {
|
|
@@ -1573,19 +1613,20 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1573
1613
|
'react-dom': 'ReactDOM',
|
|
1574
1614
|
'react-router-dom': 'ReactRouterDOM'
|
|
1575
1615
|
})[pkgName] || pkgName, getExternalValue = (pkgName)=>`window ${getExternalLibraryName(pkgName)}`, prebundleDeps = async ({ unpackConfig })=>{
|
|
1576
|
-
var _unpackConfig_dev;
|
|
1577
|
-
let count = {
|
|
1616
|
+
var _unpackConfig_dev, externals;
|
|
1617
|
+
let existExternals, cacheDir, count = {
|
|
1578
1618
|
total: 0,
|
|
1579
1619
|
bundled: 0
|
|
1580
1620
|
}, 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 = ()=>{
|
|
1581
|
-
logUpdate(`${colors.magenta(
|
|
1621
|
+
logUpdate(`${colors.magenta('»')} optimizing dependencies (${count.bundled}/${count.total})`), count.total === count.bundled + failedDeps.length && console.log();
|
|
1582
1622
|
}, 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 = [
|
|
1583
|
-
...((externals)=>{
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1623
|
+
...(externals = unpackConfig.externals, existExternals = new Set(), Array.isArray(externals) ? externals.forEach((item)=>{
|
|
1624
|
+
isPlainObject(item) && Object.keys(item).forEach((key)=>{
|
|
1625
|
+
existExternals.add(key);
|
|
1626
|
+
});
|
|
1627
|
+
}) : isPlainObject(externals) && Object.keys(externals).forEach((key)=>{
|
|
1628
|
+
existExternals.add(key);
|
|
1629
|
+
}), Array.from(existExternals) || []),
|
|
1589
1630
|
...userOptions.exclude || []
|
|
1590
1631
|
], shouldIncludeDeps = Object.keys(packageJson.dependencies).filter((pkgName)=>!excludeDeps.includes(pkgName)), noEntryDeps = [], needBundleDeps = shouldIncludeDeps.map((pkgName)=>{
|
|
1591
1632
|
let packageJson = JSON.parse(node_fs.readFileSync(node_path.resolve(root, 'node_modules', pkgName, 'package.json'), 'utf-8')), version = packageJson.version;
|
|
@@ -1731,17 +1772,17 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1731
1772
|
resolve(isFailed ? void 0 : getResult());
|
|
1732
1773
|
});
|
|
1733
1774
|
});
|
|
1734
|
-
}))(depInfo)))
|
|
1735
|
-
node_fs.existsSync(cacheDir) || node_fs.mkdirSync(cacheDir, {
|
|
1775
|
+
}))(depInfo)));
|
|
1776
|
+
cacheDir = node_path.dirname(failedDepsCachePath), node_fs.existsSync(cacheDir) || node_fs.mkdirSync(cacheDir, {
|
|
1736
1777
|
recursive: !0
|
|
1737
1778
|
}), 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(', '))}"`);
|
|
1738
1779
|
let cachePath = node_path.resolve(root, TEMP_DIR, 'umd'), app = express();
|
|
1739
1780
|
app.use(cors()), app.use("/umd", express.static(cachePath));
|
|
1740
1781
|
let port = await getPort(), staticServer = app.listen(port, ()=>{});
|
|
1741
|
-
|
|
1742
|
-
let
|
|
1782
|
+
addRestartCleaner(()=>new Promise((resolve)=>staticServer.close(()=>resolve())));
|
|
1783
|
+
let externals1 = {}, jsAssets = [], cssAssets = [], preJsAssets = [];
|
|
1743
1784
|
return bundledDeps.filter(Boolean).forEach((dep)=>{
|
|
1744
|
-
dep && (
|
|
1785
|
+
dep && (externals1[dep.name] = getExternalValue(dep.name), dep.assets.forEach((absPath)=>{
|
|
1745
1786
|
let relativePath = node_path.relative(cachePath, absPath), preDeps = [
|
|
1746
1787
|
'react',
|
|
1747
1788
|
'react-dom',
|
|
@@ -1759,10 +1800,10 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1759
1800
|
}
|
|
1760
1801
|
}));
|
|
1761
1802
|
}), unpackConfig.externals = Array.isArray(unpackConfig.externals) ? [
|
|
1762
|
-
|
|
1803
|
+
externals1,
|
|
1763
1804
|
...unpackConfig.externals
|
|
1764
1805
|
] : {
|
|
1765
|
-
...
|
|
1806
|
+
...externals1,
|
|
1766
1807
|
...unpackConfig.externals
|
|
1767
1808
|
}, unpackConfig.plugins.push({
|
|
1768
1809
|
name: 'unpack:prebundle',
|
|
@@ -1787,7 +1828,7 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1787
1828
|
}), unpackConfig;
|
|
1788
1829
|
};
|
|
1789
1830
|
async function unpackDev(originalUnpackConfig) {
|
|
1790
|
-
var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1, _unpackConfig_server2;
|
|
1831
|
+
var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1, _unpackConfig_server2, _unpackConfig_server3;
|
|
1791
1832
|
let unpackConfig = originalUnpackConfig;
|
|
1792
1833
|
(null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.prebundle) && (unpackConfig = await prebundleDeps({
|
|
1793
1834
|
unpackConfig
|
|
@@ -1822,67 +1863,90 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1822
1863
|
var _req_headers_accept;
|
|
1823
1864
|
(null == (_req_headers_accept = req.headers.accept) ? void 0 : _req_headers_accept.includes('html')) && (req.url = '/index.html'), next();
|
|
1824
1865
|
}), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1825
|
-
let server = new
|
|
1826
|
-
await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.
|
|
1827
|
-
|
|
1828
|
-
|
|
1866
|
+
let server = new RspackDevServer(devServerOptions, compiler);
|
|
1867
|
+
await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.3.0`)} ${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(async ()=>await server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())));
|
|
1868
|
+
let open = null == (_unpackConfig_server3 = unpackConfig.server) ? void 0 : _unpackConfig_server3.open, url = isString(open) ? open : `http://localhost:${port}`;
|
|
1869
|
+
open && openBrowser(url), setupCliShortcuts({
|
|
1870
|
+
openPage: async ()=>{
|
|
1871
|
+
await openBrowser(url);
|
|
1872
|
+
},
|
|
1873
|
+
closeServer: async ()=>{
|
|
1874
|
+
await cleanUpBeforeRestart(), process.exit(0);
|
|
1875
|
+
},
|
|
1876
|
+
printUrls: ()=>{
|
|
1877
|
+
var _unpackConfig_server;
|
|
1878
|
+
printAddressUrls(port, null == (_unpackConfig_server = unpackConfig.server) ? void 0 : _unpackConfig_server.host);
|
|
1879
|
+
},
|
|
1880
|
+
restartServer: async ()=>{
|
|
1881
|
+
logger_logger.clear(), await cleanUpBeforeRestart(), createUnpack({
|
|
1882
|
+
cwd: currentDevUnpackConfig.root,
|
|
1883
|
+
config: currentDevUnpackConfig
|
|
1884
|
+
}).dev();
|
|
1885
|
+
}
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
function printAddressUrls(port, host) {
|
|
1889
|
+
let addressUrls = getAddressUrls({
|
|
1890
|
+
port
|
|
1891
|
+
}), colorPrefix = colors.green('➜');
|
|
1892
|
+
addressUrls.forEach((addr, index)=>{
|
|
1829
1893
|
let url;
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1894
|
+
if (!host && 0 !== index) {
|
|
1895
|
+
1 === index && console.log(` ${colors.dim(colorPrefix)} ${colors.bold(colors.dim('Network:'))} ${colors.dim('use')} ${colors.bold('--host')} ${colors.dim('to expose')}`);
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1898
|
+
console.log(` ${colorPrefix} ${colors.bold(addr.label)}${(url = addr.url, colors.cyan(url.replace(/:(\d+)\//, (_, port)=>`:${colors.bold(port)}/`)))}`);
|
|
1833
1899
|
});
|
|
1834
|
-
let open = null == (_unpackConfig_server2 = unpackConfig.server) ? void 0 : _unpackConfig_server2.open;
|
|
1835
|
-
if (open) {
|
|
1836
|
-
let url = isString(open) ? open : `http://localhost:${port}`;
|
|
1837
|
-
await openBrowser(url);
|
|
1838
|
-
}
|
|
1839
1900
|
}
|
|
1840
1901
|
function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
1841
|
-
let resolveConfig = ()=>
|
|
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
|
-
|
|
1875
|
-
|
|
1902
|
+
let resolveConfig = ()=>{
|
|
1903
|
+
let defaultConfig = {
|
|
1904
|
+
root: cwd,
|
|
1905
|
+
build: {
|
|
1906
|
+
outDir: 'dist',
|
|
1907
|
+
minify: isProd(),
|
|
1908
|
+
sourceMap: !isProd() && 'cheap-module-source-map',
|
|
1909
|
+
parallel: !0,
|
|
1910
|
+
filenameHash: !0,
|
|
1911
|
+
target: 'es2022'
|
|
1912
|
+
},
|
|
1913
|
+
dev: {
|
|
1914
|
+
lazyCompilation: !0
|
|
1915
|
+
},
|
|
1916
|
+
server: {
|
|
1917
|
+
port: 3000
|
|
1918
|
+
},
|
|
1919
|
+
html: {
|
|
1920
|
+
mountId: 'root'
|
|
1921
|
+
},
|
|
1922
|
+
css: {
|
|
1923
|
+
modules: !0,
|
|
1924
|
+
transformer: 'postcss',
|
|
1925
|
+
sourceMap: !1
|
|
1926
|
+
},
|
|
1927
|
+
performance: {
|
|
1928
|
+
chunkSplit: {
|
|
1929
|
+
strategy: 'split-by-experience'
|
|
1930
|
+
}
|
|
1931
|
+
},
|
|
1932
|
+
typeCheck: !0,
|
|
1933
|
+
envPrefix: [
|
|
1934
|
+
'PUBLIC_'
|
|
1935
|
+
]
|
|
1936
|
+
};
|
|
1937
|
+
return global.__unpack_caller_name = callerName, {
|
|
1938
|
+
...mergeConfig(defaultConfig, config),
|
|
1876
1939
|
_context: {
|
|
1877
1940
|
callerName,
|
|
1878
|
-
version: "3.
|
|
1941
|
+
version: "3.3.0"
|
|
1879
1942
|
}
|
|
1880
|
-
}
|
|
1943
|
+
};
|
|
1944
|
+
};
|
|
1881
1945
|
return {
|
|
1882
1946
|
build: async ({ watch } = {})=>{
|
|
1883
1947
|
setNodeEnv(watch ? 'development' : 'production');
|
|
1884
1948
|
let config = resolveConfig();
|
|
1885
|
-
console.log(colors.rainbow(`${callerName} v3.
|
|
1949
|
+
console.log(colors.rainbow(`${callerName} v3.3.0`), colors.green(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
|
|
1886
1950
|
},
|
|
1887
1951
|
dev: async ()=>{
|
|
1888
1952
|
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
|
|
@@ -1904,4 +1968,5 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
|
|
|
1904
1968
|
...options
|
|
1905
1969
|
});
|
|
1906
1970
|
}
|
|
1907
|
-
|
|
1971
|
+
var __webpack_exports__CSS_NAMED_EXPORT = !1;
|
|
1972
|
+
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 };
|