@unpackjs/core 4.7.3 → 4.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +46 -15
- package/dist-types/cli/index.d.ts.map +1 -1
- package/dist-types/port.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import * as __rspack_external_path from "path";
|
|
|
11
11
|
import * as __rspack_external_url from "url";
|
|
12
12
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
13
13
|
import { Compilation, rspack } from "@rspack/core";
|
|
14
|
+
import { exec, spawn, spawnSync } from "node:child_process";
|
|
14
15
|
import node_fs, { stat as external_node_fs_stat, unwatchFile, watch as external_node_fs_watch, watchFile } from "node:fs";
|
|
15
16
|
import node_readline from "node:readline";
|
|
16
17
|
import { createHash } from "node:crypto";
|
|
@@ -20,7 +21,6 @@ import { format as external_node_util_format, promisify } from "node:util";
|
|
|
20
21
|
import node_zlib from "node:zlib";
|
|
21
22
|
import node_net from "node:net";
|
|
22
23
|
import { RspackDevServer } from "@rspack/dev-server";
|
|
23
|
-
import { exec, spawn } from "node:child_process";
|
|
24
24
|
import { EventEmitter } from "node:events";
|
|
25
25
|
import { lstat, open as promises_open, readdir, realpath as promises_realpath, stat as promises_stat } from "node:fs/promises";
|
|
26
26
|
import { Readable } from "node:stream";
|
|
@@ -4464,10 +4464,10 @@ let UNOCSS_CONFIG_FILES = [
|
|
|
4464
4464
|
if (!view) return (css)=>css;
|
|
4465
4465
|
let prefix = {};
|
|
4466
4466
|
return view.trim().replace(/(\\*)\\(["'`\\])/g, (_, bs, char)=>(prefix[char] = bs.replace(/\\\\/g, '\\'), '')), (css)=>css.replace(/["'`\\]/g, (v)=>(prefix[v] || '') + v);
|
|
4467
|
-
}, main_0 = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js"), DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm, checkPortOnHost = (port, host)=>new Promise((resolve
|
|
4467
|
+
}, main_0 = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js"), DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm, isIpv6LinkLocal = (address)=>address.toLowerCase().startsWith('fe80:'), checkPortOnHost = (port, host)=>new Promise((resolve)=>{
|
|
4468
4468
|
let server = node_net.createServer();
|
|
4469
|
-
server.
|
|
4470
|
-
'EADDRINUSE' === error.code ? resolve('occupied') :
|
|
4469
|
+
server.once('error', (error)=>{
|
|
4470
|
+
'EADDRINUSE' === error.code ? resolve('occupied') : resolve('unsupported');
|
|
4471
4471
|
}), server.listen(null === host ? {
|
|
4472
4472
|
port,
|
|
4473
4473
|
exclusive: !0
|
|
@@ -4488,19 +4488,39 @@ let UNOCSS_CONFIG_FILES = [
|
|
|
4488
4488
|
'available' === result && (hasSupportedHost = !0);
|
|
4489
4489
|
}
|
|
4490
4490
|
return hasSupportedHost;
|
|
4491
|
-
},
|
|
4492
|
-
|
|
4491
|
+
}, getRandomPort = async ()=>new Promise((resolve, reject)=>{
|
|
4492
|
+
let server = node_net.createServer();
|
|
4493
|
+
server.once('error', reject), server.listen({
|
|
4494
|
+
port: 0,
|
|
4495
|
+
exclusive: !0
|
|
4496
|
+
}, ()=>{
|
|
4497
|
+
let address = server.address(), resolvedPort = 'object' == typeof address && address ? address.port : 0;
|
|
4498
|
+
server.close((error)=>{
|
|
4499
|
+
error ? reject(error) : resolvedPort > 0 ? resolve(resolvedPort) : reject(Error('Failed to resolve random available port'));
|
|
4500
|
+
});
|
|
4501
|
+
});
|
|
4502
|
+
}), getPort = async (startPort = 45678)=>{
|
|
4503
|
+
let rawStartPort = Number.isFinite(startPort) ? Math.floor(startPort) : 45678;
|
|
4504
|
+
if (0 === rawStartPort) return getRandomPort();
|
|
4505
|
+
let normalizedStartPort = Math.max(1, Math.min(65535, rawStartPort)), hosts = (()=>{
|
|
4493
4506
|
let hosts = [
|
|
4494
4507
|
'0.0.0.0'
|
|
4495
4508
|
];
|
|
4496
4509
|
try {
|
|
4497
4510
|
let interfaces = node_os.networkInterfaces();
|
|
4498
|
-
for (let interfaceName of Object.keys(interfaces))
|
|
4511
|
+
for (let interfaceName of Object.keys(interfaces)){
|
|
4512
|
+
let infos = interfaces[interfaceName];
|
|
4513
|
+
if (infos) for (let info of infos){
|
|
4514
|
+
if (!info?.address) continue;
|
|
4515
|
+
let family = info.family;
|
|
4516
|
+
('IPv6' === family || 6 === family) && isIpv6LinkLocal(info.address) || hosts.push(info.address);
|
|
4517
|
+
}
|
|
4518
|
+
}
|
|
4499
4519
|
} catch {}
|
|
4500
4520
|
return hosts.push(null), Array.from(new Set(hosts));
|
|
4501
4521
|
})();
|
|
4502
4522
|
for(let port = normalizedStartPort; port <= 65535; port++)if (await getPortAvailability(port, hosts)) return port;
|
|
4503
|
-
for(let port =
|
|
4523
|
+
for(let port = 1; port < normalizedStartPort; port++)if (await getPortAvailability(port, hosts)) return port;
|
|
4504
4524
|
throw Error('No available port found');
|
|
4505
4525
|
}, TRANSFORM_TIMING_STORE = Symbol.for('unpack:transformTimingMap'), PLUGIN_CONTEXT_STORE = Symbol.for('unpack:pluginContextStore'), globalScope = globalThis;
|
|
4506
4526
|
globalScope[TRANSFORM_TIMING_STORE] ??= new WeakMap(), globalScope[PLUGIN_CONTEXT_STORE] ??= new WeakMap();
|
|
@@ -4648,7 +4668,7 @@ class JsMinifyPlugin {
|
|
|
4648
4668
|
apply(compiler) {
|
|
4649
4669
|
let meta = JSON.stringify({
|
|
4650
4670
|
name: jsMinify_PLUGIN_NAME,
|
|
4651
|
-
version: "4.7.
|
|
4671
|
+
version: "4.7.4",
|
|
4652
4672
|
options: this.minifyOptions
|
|
4653
4673
|
});
|
|
4654
4674
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -5382,7 +5402,7 @@ async function unpackDev(originalConfig) {
|
|
|
5382
5402
|
...middlewares
|
|
5383
5403
|
]);
|
|
5384
5404
|
let server = new RspackDevServer(devServerOptions, compiler);
|
|
5385
|
-
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v4.7.
|
|
5405
|
+
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v4.7.4`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - getUnpackStartTime()))} ${colors.dim('ms')}\n`), printServerUrls({
|
|
5386
5406
|
port,
|
|
5387
5407
|
host: unpackConfig.server.host,
|
|
5388
5408
|
base: unpackConfig.base
|
|
@@ -5396,7 +5416,7 @@ async function unpackDev(originalConfig) {
|
|
|
5396
5416
|
function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'unpack' }) {
|
|
5397
5417
|
let _context = {
|
|
5398
5418
|
callerName,
|
|
5399
|
-
version: "4.7.
|
|
5419
|
+
version: "4.7.4",
|
|
5400
5420
|
cachePath: 'node_modules/.unpack'
|
|
5401
5421
|
}, resolveConfig = (mode)=>{
|
|
5402
5422
|
let rootPath, outputPath, basePath, cachedTraceMap, fs, isValidMethodName, parseFrame, formatOriginalLocation, formatFullStack, resolveErrorLocationAndStack, root, alias, shouldTransformDeepImport, preJsAssets, jsAssets, cssAssets, bundledDepsCachePath, deepImportPkgPattern, deepImportRegex, plugin, tsconfigPath, root1, uno, generated, configOrPath, defaults, VIRTUAL_UNO_CSS_ID, rootDir, isMpa, unoConfig, configFilePath, unpackConfigPath, tokens, requestedLayers, tasks, unocssCacheDir, tokensCachePath, layersCachePath, timeCachePath, configHashCachePath, generatedCachePath, bundlerCacheDir, cachedTokensSize, cachedLayersSize, isCompiling, resolveUnocssConfig, flushTasks, getVirtualModuleContent, hash, restoreSkipCode, applyUnoTransformers, options, rootPath1, registerCode, namesCode, defaultConfig = {
|
|
@@ -6576,7 +6596,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
|
|
|
6576
6596
|
let mode = watch ? 'development' : 'production';
|
|
6577
6597
|
setNodeEnv(mode);
|
|
6578
6598
|
let config = resolveConfig(mode);
|
|
6579
|
-
console.log(colors.brand(`${callerName} v4.7.
|
|
6599
|
+
console.log(colors.brand(`${callerName} v4.7.4`), colors.cyan(`building for ${mode}...`)), await unpackBuild(config);
|
|
6580
6600
|
},
|
|
6581
6601
|
dev: async ()=>{
|
|
6582
6602
|
setUnpackStartTime(performance.now());
|
|
@@ -7720,7 +7740,7 @@ async function setupUnpack(cliOptions, command) {
|
|
|
7720
7740
|
function runCLI() {
|
|
7721
7741
|
let cli = ((name = "")=>new CAC(name))('unpack');
|
|
7722
7742
|
cli.option('-c, --config <file>', 'Use specified config file').option('-r, --root <dir>', 'Specify root directory').option('-d, --debug', 'Show debug logs');
|
|
7723
|
-
let devCommand = cli.command('', 'Start dev server').alias('dev'), buildCommand = cli.command('build', 'Build for production'), cleanCommand = cli.command('clean', 'Clean cache directory');
|
|
7743
|
+
let devCommand = cli.command('', 'Start dev server').alias('dev'), buildCommand = cli.command('build', 'Build for production'), cleanCommand = cli.command('clean', 'Clean cache directory'), upCommand = cli.command('up', 'Upgrade unpack packages to the latest');
|
|
7724
7744
|
buildCommand.option('-w, --watch', 'Rebuilds when modules have changed on disk').option('--analyze', 'Analyze the size of output files').action(withErrorHandling(async (options)=>{
|
|
7725
7745
|
let { unpack } = await setupUnpack(options, 'build');
|
|
7726
7746
|
await unpack.build({
|
|
@@ -7729,7 +7749,18 @@ function runCLI() {
|
|
|
7729
7749
|
})), cleanCommand.action(withErrorHandling(async (options)=>{
|
|
7730
7750
|
let { unpack } = await setupUnpack(options, 'build');
|
|
7731
7751
|
unpack.clean();
|
|
7732
|
-
}))
|
|
7752
|
+
})), upCommand.action(()=>{
|
|
7753
|
+
spawnSync('win32' === process.platform ? 'npx.cmd' : 'npx', [
|
|
7754
|
+
'--yes',
|
|
7755
|
+
'taze',
|
|
7756
|
+
'minor',
|
|
7757
|
+
'--include',
|
|
7758
|
+
'/^@unpackjs\\//',
|
|
7759
|
+
'-w'
|
|
7760
|
+
], {
|
|
7761
|
+
stdio: 'inherit'
|
|
7762
|
+
});
|
|
7763
|
+
});
|
|
7733
7764
|
let startServer = withErrorHandling(async (options)=>{
|
|
7734
7765
|
let { unpack, config } = await setupUnpack(options, 'dev'), { port, url } = await unpack.dev();
|
|
7735
7766
|
await setupCliShortcuts({
|
|
@@ -7757,7 +7788,7 @@ function runCLI() {
|
|
|
7757
7788
|
logger_logger.clear(), logger_logger.info(`${node_path.basename(file)} changed, restarting server...`), await watcher.close(), await cleanUpBeforeRestart(), startServer(options);
|
|
7758
7789
|
});
|
|
7759
7790
|
});
|
|
7760
|
-
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.7.
|
|
7791
|
+
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.7.4"), cli.parse();
|
|
7761
7792
|
}
|
|
7762
7793
|
let launch_editor = __webpack_require__("../../node_modules/.pnpm/launch-editor@2.13.1/node_modules/launch-editor/index.js");
|
|
7763
7794
|
var launch_editor_default_0 = __webpack_require__.n(launch_editor)(), src_CSS_MODULES_NAMED_EXPORT = !1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAwCA,wBAAgB,MAAM,SA+ErB"}
|
package/dist-types/port.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../src/port.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../src/port.ts"],"names":[],"mappings":"AAyFA,eAAO,MAAM,OAAO,GAAU,kBAAiB,KAAG,OAAO,CAAC,MAAM,CAkB/D,CAAA"}
|