@unpackjs/core 3.9.1 → 4.0.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/bin/unpack.js +8 -0
- package/dist/index.js +158 -88
- package/dist-types/cli/index.d.ts +2 -0
- package/dist-types/cli/index.d.ts.map +1 -0
- package/dist-types/{cliShortcuts.d.ts → cli/shortcuts.d.ts} +1 -1
- package/dist-types/cli/shortcuts.d.ts.map +1 -0
- package/dist-types/index.d.ts +1 -1
- package/dist-types/index.d.ts.map +1 -1
- package/dist-types/plugins/browserLogs.d.ts.map +1 -1
- package/dist-types/plugins/fileSize.d.ts.map +1 -1
- package/dist-types/plugins/prebundle.d.ts.map +1 -1
- package/package.json +6 -1
- package/dist-types/cliShortcuts.d.ts.map +0 -1
package/bin/unpack.js
ADDED
package/dist/index.js
CHANGED
|
@@ -7,8 +7,9 @@ import * as __rspack_external__compiled_launch_editor_index_js_29002383 from "..
|
|
|
7
7
|
import * as __rspack_external__compiled_webpack_merge_index_js_efd91626 from "../compiled/webpack-merge/index.js";
|
|
8
8
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
9
9
|
import { rspack } from "@rspack/core";
|
|
10
|
-
import node_readline from "node:readline";
|
|
11
10
|
import node_fs from "node:fs";
|
|
11
|
+
import cac from "cac";
|
|
12
|
+
import node_readline from "node:readline";
|
|
12
13
|
import node_os, { platform } from "node:os";
|
|
13
14
|
import portfinder from "portfinder";
|
|
14
15
|
import { format, promisify } from "node:util";
|
|
@@ -95,15 +96,6 @@ function convertBasicAnsiColors(input) {
|
|
|
95
96
|
return `${styleSeq}${open}`;
|
|
96
97
|
}) : '';
|
|
97
98
|
}
|
|
98
|
-
let restartCleaners = [], addRestartCleaner = (...cleaners)=>{
|
|
99
|
-
restartCleaners.push(...cleaners);
|
|
100
|
-
}, cleanUpBeforeRestart = async ()=>{
|
|
101
|
-
await Promise.all(restartCleaners.map((cleaner)=>cleaner())), restartCleaners.length = 0;
|
|
102
|
-
}, currentUnpackConfig = {}, getCurrentUnpackConfig = ()=>currentUnpackConfig, setCurrentUnpackConfig = (config)=>{
|
|
103
|
-
currentUnpackConfig = config;
|
|
104
|
-
}, unpackStartTime = 0, getUnpackStartTime = ()=>unpackStartTime, setUnpackStartTime = (time)=>{
|
|
105
|
-
unpackStartTime = time;
|
|
106
|
-
};
|
|
107
99
|
var LogColor, logger_LogColor = ((LogColor = {}).error = "red", LogColor.warn = "yellow", LogColor.info = "cyan", LogColor.ready = "green", LogColor.event = "magenta", LogColor.wait = "blue", LogColor);
|
|
108
100
|
let CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]', CSS_MODULES_EXPORTS_CONVENTION = 'camel-case', DEV_DEFAULT_FILENAME = {
|
|
109
101
|
js: 'js/[name].js',
|
|
@@ -376,58 +368,6 @@ let injectToHead = (html, script)=>html.replace(/<head(\s*[^>]*)>/i, (match)=>`$
|
|
|
376
368
|
})(type, message, ...args);
|
|
377
369
|
};
|
|
378
370
|
}), logger);
|
|
379
|
-
async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer }) {
|
|
380
|
-
let shortcuts = [
|
|
381
|
-
restartServer ? {
|
|
382
|
-
key: 'r',
|
|
383
|
-
description: 'restart server',
|
|
384
|
-
action: restartServer
|
|
385
|
-
} : null,
|
|
386
|
-
{
|
|
387
|
-
key: 'u',
|
|
388
|
-
description: 'show server url',
|
|
389
|
-
action: printUrls
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
key: 'o',
|
|
393
|
-
description: 'open in browser',
|
|
394
|
-
action: openPage
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
key: 'c',
|
|
398
|
-
description: 'clear console',
|
|
399
|
-
action: ()=>{
|
|
400
|
-
logger_logger.clear();
|
|
401
|
-
}
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
key: 'q',
|
|
405
|
-
description: 'quit',
|
|
406
|
-
action: async ()=>{
|
|
407
|
-
try {
|
|
408
|
-
await closeServer();
|
|
409
|
-
} finally{
|
|
410
|
-
process.exit(0);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
].filter(Boolean), colorPrefix = colors.brand(colors.dim('➜'));
|
|
415
|
-
help && console.log(!0 === help ? ` ${colorPrefix} ${colors.dim('press')} ${colors.bold('h + enter')} ${colors.dim('to show help')}` : ` ${colorPrefix} ${help}`);
|
|
416
|
-
let { createInterface } = await import("node:readline"), rl = createInterface({
|
|
417
|
-
input: process.stdin
|
|
418
|
-
});
|
|
419
|
-
rl.on('line', (input)=>{
|
|
420
|
-
if ('h' === input) {
|
|
421
|
-
let message = '\n Shortcuts\n';
|
|
422
|
-
for (let shortcut of shortcuts){
|
|
423
|
-
let fullDescription = `${colors.dim('press')} ${colors.bold(`${shortcut.key} + enter`)} ${colors.dim(`to ${shortcut.description}`)}`;
|
|
424
|
-
message += ` ${fullDescription}\n`;
|
|
425
|
-
}
|
|
426
|
-
console.log(message);
|
|
427
|
-
}
|
|
428
|
-
for (let shortcut of shortcuts)if (input === shortcut.key) return void shortcut.action();
|
|
429
|
-
}), addRestartCleaner(()=>rl.close());
|
|
430
|
-
}
|
|
431
371
|
var config_filename = __rspack_fileURLToPath(import.meta.url);
|
|
432
372
|
async function loadConfig({ cliOptions, command }) {
|
|
433
373
|
'build' === command ? setNodeEnv(cliOptions?.watch ? 'development' : 'production') : (setNodeEnv('development'), setDevServer(!0));
|
|
@@ -528,6 +468,14 @@ let removeDir = (dir)=>{
|
|
|
528
468
|
recursive: !0,
|
|
529
469
|
force: !0
|
|
530
470
|
});
|
|
471
|
+
}, restartCleaners = [], addRestartCleaner = (...cleaners)=>{
|
|
472
|
+
restartCleaners.push(...cleaners);
|
|
473
|
+
}, cleanUpBeforeRestart = async ()=>{
|
|
474
|
+
await Promise.all(restartCleaners.map((cleaner)=>cleaner())), restartCleaners.length = 0;
|
|
475
|
+
}, currentUnpackConfig = {}, getCurrentUnpackConfig = ()=>currentUnpackConfig, setCurrentUnpackConfig = (config)=>{
|
|
476
|
+
currentUnpackConfig = config;
|
|
477
|
+
}, unpackStartTime = 0, getUnpackStartTime = ()=>unpackStartTime, setUnpackStartTime = (time)=>{
|
|
478
|
+
unpackStartTime = time;
|
|
531
479
|
}, STYLE_IMPORT_RE = /import\s+([\s\S]+?)\s+from\s+(['"])(.*?\.(?:css|less|scss|sass))\2/g, TYPE_IMPORT_CLAUSE_RE = /^\s*type\b/, STYLE_EXT_HINTS = [
|
|
532
480
|
'.css',
|
|
533
481
|
'.less',
|
|
@@ -553,7 +501,7 @@ let COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|
|
|
|
553
501
|
function getNormalizedPluginsByHook(hook) {
|
|
554
502
|
let pluginMap = new Map();
|
|
555
503
|
return getCurrentUnpackConfig().plugins?.forEach((plugin)=>{
|
|
556
|
-
((plugin, hook)=>{
|
|
504
|
+
plugin && ((plugin, hook)=>{
|
|
557
505
|
if (!plugin[hook]) return !1;
|
|
558
506
|
let apply = plugin.apply;
|
|
559
507
|
if (!apply) return !0;
|
|
@@ -754,7 +702,7 @@ class JsMinifyPlugin {
|
|
|
754
702
|
apply(compiler) {
|
|
755
703
|
let meta = JSON.stringify({
|
|
756
704
|
name: jsMinify_PLUGIN_NAME,
|
|
757
|
-
version: "
|
|
705
|
+
version: "4.0.0",
|
|
758
706
|
options: this.minifyOptions
|
|
759
707
|
});
|
|
760
708
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -842,8 +790,9 @@ let getCompileTime = (stats)=>stats.toJson({
|
|
|
842
790
|
timings: !0
|
|
843
791
|
}).time / 1000, sameCount = 0;
|
|
844
792
|
async function compileDone(compiler, stats) {
|
|
793
|
+
if (stats.hasErrors()) return;
|
|
845
794
|
let root = compiler.options.context;
|
|
846
|
-
if (
|
|
795
|
+
if (utils_isProd()) logger_logger.ready(colors.green(`built in ${prettyTime(getCompileTime(stats))}`));
|
|
847
796
|
else {
|
|
848
797
|
let fileInfo = function(changedFiles, removedFiles, root) {
|
|
849
798
|
if (!changedFiles?.length && !removedFiles?.length) return null;
|
|
@@ -1586,7 +1535,7 @@ async function unpackDev(unpackConfig) {
|
|
|
1586
1535
|
...middlewares
|
|
1587
1536
|
]);
|
|
1588
1537
|
let server = new RspackDevServer(devServerOptions, compiler);
|
|
1589
|
-
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())}
|
|
1538
|
+
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v4.0.0${unpackConfig.performance?.cache ? ' ϟ' : ''}`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - getUnpackStartTime()))} ${colors.dim('ms')}\n`), printServerUrls({
|
|
1590
1539
|
port,
|
|
1591
1540
|
host: unpackConfig.server.host,
|
|
1592
1541
|
base: unpackConfig.base
|
|
@@ -1600,10 +1549,10 @@ async function unpackDev(unpackConfig) {
|
|
|
1600
1549
|
function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'unpack' }) {
|
|
1601
1550
|
let _context = {
|
|
1602
1551
|
callerName,
|
|
1603
|
-
version: "
|
|
1552
|
+
version: "4.0.0",
|
|
1604
1553
|
cachePath: 'node_modules/.unpack'
|
|
1605
1554
|
}, resolveConfig = (mode)=>{
|
|
1606
|
-
let rootPath, outputPath, basePath, cachedTraceMap, fs, isValidMethodName, parseFrame, formatOriginalLocation, formatFullStack, resolveErrorLocationAndStack, shouldTransformDeepImport, preJsAssets, jsAssets, cssAssets, bundledDepsCachePath, deepImportPkgPattern, deepImportRegex, root;
|
|
1555
|
+
let rootPath, outputPath, basePath, cachedTraceMap, fs, isValidMethodName, parseFrame, formatOriginalLocation, formatFullStack, resolveErrorLocationAndStack, shouldTransformDeepImport, preJsAssets, jsAssets, cssAssets, bundledDepsCachePath, deepImportPkgPattern, deepImportRegex, plugin, root;
|
|
1607
1556
|
return {
|
|
1608
1557
|
...mergeConfig({
|
|
1609
1558
|
root: cwd,
|
|
@@ -1890,18 +1839,16 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
1890
1839
|
format(cleanedTemplate, ...rest)
|
|
1891
1840
|
];
|
|
1892
1841
|
})(formattedArgs), prefix = colors.dim(`[browser ${time}]`);
|
|
1893
|
-
switch(
|
|
1842
|
+
switch(level){
|
|
1894
1843
|
case 'error':
|
|
1895
|
-
|
|
1844
|
+
console.log(colors.red(`${prefix} ${format(...outputArgs)}`));
|
|
1896
1845
|
break;
|
|
1897
1846
|
case 'warn':
|
|
1898
|
-
|
|
1847
|
+
console.log(colors.yellow(`${prefix} ${format(...outputArgs)}`));
|
|
1899
1848
|
break;
|
|
1900
1849
|
case 'debug':
|
|
1901
|
-
|
|
1850
|
+
console.log(prefix, ...outputArgs);
|
|
1902
1851
|
}
|
|
1903
|
-
} catch (e) {
|
|
1904
|
-
logger_logger.error('Failed to parse browser log payload', e);
|
|
1905
1852
|
} finally{
|
|
1906
1853
|
res.statusCode = 204, res.end();
|
|
1907
1854
|
}
|
|
@@ -1912,7 +1859,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
1912
1859
|
}),
|
|
1913
1860
|
(shouldTransformDeepImport = !1, preJsAssets = [], jsAssets = [], cssAssets = [], bundledDepsCachePath = '', deepImportPkgPattern = [
|
|
1914
1861
|
...SPECIAL_NO_ENTRY_DEPS
|
|
1915
|
-
].sort((a, b)=>b.length - a.length).map((name)=>name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'), deepImportRegex = RegExp(`import\\s+([a-zA-Z0-9_$]+)\\s+from\\s+['"]((${deepImportPkgPattern})/[^'"]+)['"]`, 'g'), {
|
|
1862
|
+
].sort((a, b)=>b.length - a.length).map((name)=>name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'), deepImportRegex = RegExp(`import\\s+([a-zA-Z0-9_$]+)\\s+from\\s+['"]((${deepImportPkgPattern})/[^'"]+)['"]`, 'g'), plugin = {
|
|
1916
1863
|
name: 'unpack:prebundle',
|
|
1917
1864
|
apply: (config, { command })=>'dev' === command && !!config.dev?.prebundle,
|
|
1918
1865
|
config: async (config, context)=>{
|
|
@@ -2144,16 +2091,15 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
2144
2091
|
return config.externals = [
|
|
2145
2092
|
externals1,
|
|
2146
2093
|
...existingExternals
|
|
2147
|
-
],
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
}) : null
|
|
2094
|
+
], shouldTransformDeepImport && (plugin.transform = {
|
|
2095
|
+
filter: {
|
|
2096
|
+
test: JSX_REGEX
|
|
2097
|
+
},
|
|
2098
|
+
handler: (code)=>SPECIAL_NO_ENTRY_DEPS.some((pkg)=>code.includes(pkg)) ? code.replace(deepImportRegex, (_, localName, importPath, pkgName)=>{
|
|
2099
|
+
let exportName = pathToExportIdentifier(importPath.slice(pkgName.length + 1));
|
|
2100
|
+
return `import { ${exportName} as ${localName} } from '${pkgName}'`;
|
|
2101
|
+
}) : null
|
|
2102
|
+
}), config;
|
|
2157
2103
|
},
|
|
2158
2104
|
transformHtml: (html)=>injectToHead(html, preJsAssets.sort((a, b)=>a.order - b.order).map((item)=>item.path).map((item)=>`<script defer src="${item}"></script>`).join('')),
|
|
2159
2105
|
setupMiddlewares: (middlewares)=>[
|
|
@@ -2197,7 +2143,9 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
2197
2143
|
root = config.root;
|
|
2198
2144
|
},
|
|
2199
2145
|
buildEnd: async (options)=>{
|
|
2200
|
-
let { stats } = options
|
|
2146
|
+
let { stats } = options;
|
|
2147
|
+
if (stats.hasErrors()) return;
|
|
2148
|
+
let chunkGroups = [
|
|
2201
2149
|
{
|
|
2202
2150
|
type: 'HTML',
|
|
2203
2151
|
color: 'green',
|
|
@@ -2270,7 +2218,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
2270
2218
|
let mode = watch ? 'development' : 'production';
|
|
2271
2219
|
setNodeEnv(mode);
|
|
2272
2220
|
let config = resolveConfig(mode);
|
|
2273
|
-
console.log(colors.brand(`${callerName}
|
|
2221
|
+
console.log(colors.brand(`${callerName} v4.0.0${config.performance?.cache ? ' ϟ' : ''}`), colors.cyan(`building for ${mode}...`)), await unpackBuild(config);
|
|
2274
2222
|
},
|
|
2275
2223
|
dev: async ()=>{
|
|
2276
2224
|
setUnpackStartTime(performance.now());
|
|
@@ -2298,5 +2246,127 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
|
|
|
2298
2246
|
...options
|
|
2299
2247
|
});
|
|
2300
2248
|
}
|
|
2249
|
+
async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer }) {
|
|
2250
|
+
let shortcuts = [
|
|
2251
|
+
restartServer ? {
|
|
2252
|
+
key: 'r',
|
|
2253
|
+
description: 'restart server',
|
|
2254
|
+
action: restartServer
|
|
2255
|
+
} : null,
|
|
2256
|
+
{
|
|
2257
|
+
key: 'u',
|
|
2258
|
+
description: 'show server url',
|
|
2259
|
+
action: printUrls
|
|
2260
|
+
},
|
|
2261
|
+
{
|
|
2262
|
+
key: 'o',
|
|
2263
|
+
description: 'open in browser',
|
|
2264
|
+
action: openPage
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
key: 'c',
|
|
2268
|
+
description: 'clear console',
|
|
2269
|
+
action: ()=>{
|
|
2270
|
+
logger_logger.clear();
|
|
2271
|
+
}
|
|
2272
|
+
},
|
|
2273
|
+
{
|
|
2274
|
+
key: 'q',
|
|
2275
|
+
description: 'quit',
|
|
2276
|
+
action: async ()=>{
|
|
2277
|
+
try {
|
|
2278
|
+
await closeServer();
|
|
2279
|
+
} finally{
|
|
2280
|
+
process.exit(0);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
].filter(Boolean), colorPrefix = colors.brand(colors.dim('➜'));
|
|
2285
|
+
help && console.log(!0 === help ? ` ${colorPrefix} ${colors.dim('press')} ${colors.bold('h + enter')} ${colors.dim('to show help')}` : ` ${colorPrefix} ${help}`);
|
|
2286
|
+
let { createInterface } = await import("node:readline"), rl = createInterface({
|
|
2287
|
+
input: process.stdin
|
|
2288
|
+
});
|
|
2289
|
+
rl.on('line', (input)=>{
|
|
2290
|
+
if ('h' === input) {
|
|
2291
|
+
let message = '\n Shortcuts\n';
|
|
2292
|
+
for (let shortcut of shortcuts){
|
|
2293
|
+
let fullDescription = `${colors.dim('press')} ${colors.bold(`${shortcut.key} + enter`)} ${colors.dim(`to ${shortcut.description}`)}`;
|
|
2294
|
+
message += ` ${fullDescription}\n`;
|
|
2295
|
+
}
|
|
2296
|
+
console.log(message);
|
|
2297
|
+
}
|
|
2298
|
+
for (let shortcut of shortcuts)if (input === shortcut.key) return void shortcut.action();
|
|
2299
|
+
}), addRestartCleaner(()=>rl.close());
|
|
2300
|
+
}
|
|
2301
|
+
var cli_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
2302
|
+
let withErrorHandling = (action)=>async (options)=>{
|
|
2303
|
+
try {
|
|
2304
|
+
await action(options);
|
|
2305
|
+
} catch (e) {
|
|
2306
|
+
logger_logger.error(e), process.exit(1);
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2309
|
+
async function setupUnpack(cliOptions, command) {
|
|
2310
|
+
cliOptions.debug && (process.env.DEBUG = 'unpack');
|
|
2311
|
+
let userConfig = await loadConfig({
|
|
2312
|
+
cliOptions,
|
|
2313
|
+
command
|
|
2314
|
+
}), pluginReactPath = node_path.resolve(cli_dirname, '../../plugin-react/dist/index.js');
|
|
2315
|
+
if (node_fs.existsSync(pluginReactPath)) {
|
|
2316
|
+
let { pluginReact } = await import(pluginReactPath);
|
|
2317
|
+
userConfig.plugins ? userConfig.plugins.unshift(pluginReact()) : userConfig.plugins = [
|
|
2318
|
+
pluginReact()
|
|
2319
|
+
];
|
|
2320
|
+
}
|
|
2321
|
+
return {
|
|
2322
|
+
unpack: createUnpack({
|
|
2323
|
+
cwd: userConfig.root,
|
|
2324
|
+
config: userConfig
|
|
2325
|
+
}),
|
|
2326
|
+
config: userConfig
|
|
2327
|
+
};
|
|
2328
|
+
}
|
|
2329
|
+
function runCLI() {
|
|
2330
|
+
let cli = cac('unpack');
|
|
2331
|
+
cli.option('-c, --config <file>', 'Use specified config file').option('-r, --root <dir>', 'Specify root directory').option('-d, --debug', 'Show debug logs');
|
|
2332
|
+
let devCommand = cli.command('', 'Start dev server').alias('dev'), buildCommand = cli.command('build', 'Build for production'), cleanCommand = cli.command('clean', 'Clean cache directory');
|
|
2333
|
+
buildCommand.option('-w, --watch', 'Rebuilds when modules have changed on disk').option('--analyze', 'Analyze the size of output files').action(withErrorHandling(async (options)=>{
|
|
2334
|
+
let { unpack } = await setupUnpack(options, 'build');
|
|
2335
|
+
await unpack.build({
|
|
2336
|
+
watch: options.watch
|
|
2337
|
+
});
|
|
2338
|
+
})), cleanCommand.action(withErrorHandling(async (options)=>{
|
|
2339
|
+
let { unpack } = await setupUnpack(options, 'build');
|
|
2340
|
+
unpack.clean();
|
|
2341
|
+
}));
|
|
2342
|
+
let startServer = withErrorHandling(async (options)=>{
|
|
2343
|
+
let { unpack, config } = await setupUnpack(options, 'dev'), { port, url } = await unpack.dev();
|
|
2344
|
+
await setupCliShortcuts({
|
|
2345
|
+
openPage: async ()=>{
|
|
2346
|
+
await openBrowser(url);
|
|
2347
|
+
},
|
|
2348
|
+
closeServer: async ()=>{
|
|
2349
|
+
await cleanUpBeforeRestart(), process.exit(0);
|
|
2350
|
+
},
|
|
2351
|
+
printUrls: ()=>{
|
|
2352
|
+
printServerUrls({
|
|
2353
|
+
port,
|
|
2354
|
+
host: config.server.host,
|
|
2355
|
+
base: config.base
|
|
2356
|
+
});
|
|
2357
|
+
},
|
|
2358
|
+
restartServer: async ()=>{
|
|
2359
|
+
logger_logger.clear(), await cleanUpBeforeRestart(), startServer(options);
|
|
2360
|
+
}
|
|
2361
|
+
});
|
|
2362
|
+
let watcher = await createChokidar([
|
|
2363
|
+
'unpack.config.*'
|
|
2364
|
+
], config.root);
|
|
2365
|
+
watcher.on('change', async (file)=>{
|
|
2366
|
+
logger_logger.clear(), logger_logger.info(`${node_path.basename(file)} changed, restarting server...`), await watcher.close(), await cleanUpBeforeRestart(), startServer(options);
|
|
2367
|
+
});
|
|
2368
|
+
});
|
|
2369
|
+
devCommand.option('-o, --open [url]', 'Open browser on startup').option('--port <port>', 'Specify port').option('--host', 'Expose hostname').action(startServer), cli.help(), cli.version("4.0.0"), cli.parse();
|
|
2370
|
+
}
|
|
2301
2371
|
var src_CSS_MODULES_NAMED_EXPORT = !1;
|
|
2302
|
-
export { ALL_INTERFACES_IPV4, CSS_MODULES_EXPORTS_CONVENTION, CSS_MODULES_LOCAL_IDENT_NAME, DEV_DEFAULT_FILENAME, JSX_REGEX, JS_REGEX, LOCALHOST, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, SCRIPT_REGEX, TEMPLATE_CONTENT, addRestartCleaner, cleanUpBeforeRestart, clearLine, colors, convertBasicAnsiColors, createChokidar, createUnpack, debounce, defineConfig, esVersionToBrowserslist, findExists, getAddressUrls, getCompiledPkgPath, getCurrentUnpackConfig, getHtmlTemplateOrContent, getIpv4Interfaces, getNodeEnv, getOrSetDefault, getPathInJs, getPort, getTime, getUnpackStartTime, getUserDepPath, getUserDepVersion, injectToHead, isBoolean, isDebug, isDev, isEmptyDir, isFileExists, isFileSync, isFunction, isNodeVersionAtLeast, isObject, isPlainObject, isRegExp, isString, isUndefined, isWatch, isWin, launchEditor, loadConfig, logUpdate, logger_LogColor as LogColor, logger_logger as logger, mergeConfig, normalizePublicPath, openBrowser, pLimit, pathExists, pathToExportIdentifier, prettyTime, printServerUrls, removeDir, resolveConfigPath, rspack, set, setCurrentUnpackConfig, setDevServer, setNodeEnv, setUnpackStartTime,
|
|
2372
|
+
export { ALL_INTERFACES_IPV4, CSS_MODULES_EXPORTS_CONVENTION, CSS_MODULES_LOCAL_IDENT_NAME, DEV_DEFAULT_FILENAME, JSX_REGEX, JS_REGEX, LOCALHOST, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, SCRIPT_REGEX, TEMPLATE_CONTENT, addRestartCleaner, cleanUpBeforeRestart, clearLine, colors, convertBasicAnsiColors, createChokidar, createUnpack, debounce, defineConfig, esVersionToBrowserslist, findExists, getAddressUrls, getCompiledPkgPath, getCurrentUnpackConfig, getHtmlTemplateOrContent, getIpv4Interfaces, getNodeEnv, getOrSetDefault, getPathInJs, getPort, getTime, getUnpackStartTime, getUserDepPath, getUserDepVersion, injectToHead, isBoolean, isDebug, isDev, isEmptyDir, isFileExists, isFileSync, isFunction, isNodeVersionAtLeast, isObject, isPlainObject, isRegExp, isString, isUndefined, isWatch, isWin, launchEditor, loadConfig, logUpdate, logger_LogColor as LogColor, logger_logger as logger, mergeConfig, normalizePublicPath, openBrowser, pLimit, pathExists, pathToExportIdentifier, prettyTime, printServerUrls, removeDir, resolveConfigPath, rspack, runCLI, set, setCurrentUnpackConfig, setDevServer, setNodeEnv, setUnpackStartTime, src_CSS_MODULES_NAMED_EXPORT as CSS_MODULES_NAMED_EXPORT, trackPerformance, utils_isDevServer as isDevServer, utils_isProd as isProd };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAiDA,wBAAgB,MAAM,SAuErB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortcuts.d.ts","sourceRoot":"","sources":["../../src/cli/shortcuts.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACnC,CAAA;AAED,wBAAsB,iBAAiB,CAAC,EACtC,IAAW,EACX,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,GACd,EAAE;IACD,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7B,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC,iBAsEA"}
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,MAAM,CAAA;AACpB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserLogs.d.ts","sourceRoot":"","sources":["../../src/plugins/browserLogs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browserLogs.d.ts","sourceRoot":"","sources":["../../src/plugins/browserLogs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AA6B7C,eAAO,MAAM,iBAAiB,QAAO,YAgZpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileSize.d.ts","sourceRoot":"","sources":["../../src/plugins/fileSize.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AA+B7C,eAAO,MAAM,cAAc,QAAO,
|
|
1
|
+
{"version":3,"file":"fileSize.d.ts","sourceRoot":"","sources":["../../src/plugins/fileSize.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AA+B7C,eAAO,MAAM,cAAc,QAAO,YA0GjC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prebundle.d.ts","sourceRoot":"","sources":["../../src/plugins/prebundle.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,WAAW,CAAA;AAkGnE,eAAO,MAAM,eAAe,QAAO,
|
|
1
|
+
{"version":3,"file":"prebundle.d.ts","sourceRoot":"","sources":["../../src/plugins/prebundle.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,WAAW,CAAA;AAkGnE,eAAO,MAAM,eAAe,QAAO,YAiZlC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpackjs/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "An Rspack-based build tool",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"unpack": "./bin/unpack.js"
|
|
8
|
+
},
|
|
6
9
|
"exports": {
|
|
7
10
|
".": {
|
|
8
11
|
"types": "./dist-types/index.d.ts",
|
|
@@ -16,6 +19,7 @@
|
|
|
16
19
|
"authors": [],
|
|
17
20
|
"license": "MIT",
|
|
18
21
|
"files": [
|
|
22
|
+
"bin",
|
|
19
23
|
"static",
|
|
20
24
|
"dist",
|
|
21
25
|
"compiled",
|
|
@@ -39,6 +43,7 @@
|
|
|
39
43
|
"@rsdoctor/rspack-plugin": "1.5.0",
|
|
40
44
|
"@rspack/core": "1.7.2",
|
|
41
45
|
"@rspack/dev-server": "1.1.5",
|
|
46
|
+
"cac": "6.7.14",
|
|
42
47
|
"chokidar": "5.0.0",
|
|
43
48
|
"dotenv-expand": "12.0.3",
|
|
44
49
|
"jiti": "2.6.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cliShortcuts.d.ts","sourceRoot":"","sources":["../src/cliShortcuts.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACnC,CAAA;AAED,wBAAsB,iBAAiB,CAAC,EACtC,IAAW,EACX,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,GACd,EAAE;IACD,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7B,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC,iBAsEA"}
|