@unpackjs/core 3.3.7 → 3.4.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/dist/index.cjs +58 -19
- package/dist/index.js +55 -19
- package/dist/typedCssModulesLoader.mjs +24 -11
- package/dist-types/colors.d.ts +29 -4
- package/dist-types/colors.d.ts.map +1 -1
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
|
@@ -88,9 +88,10 @@ for(var __webpack_i__ in (()=>{
|
|
|
88
88
|
isWin: ()=>isWin,
|
|
89
89
|
prettyTime: ()=>prettyTime,
|
|
90
90
|
setupCliShortcuts: ()=>setupCliShortcuts,
|
|
91
|
-
|
|
91
|
+
convertBasicAnsiColors: ()=>convertBasicAnsiColors,
|
|
92
92
|
THREAD_OPTIONS: ()=>THREAD_OPTIONS,
|
|
93
93
|
createUnpack: ()=>createUnpack,
|
|
94
|
+
loadConfig: ()=>loadConfig,
|
|
94
95
|
setDevServer: ()=>setDevServer,
|
|
95
96
|
EXPORT_LOCALS_CONVENTION: ()=>EXPORT_LOCALS_CONVENTION,
|
|
96
97
|
isFileExists: ()=>isFileExists,
|
|
@@ -106,16 +107,53 @@ for(var __webpack_i__ in (()=>{
|
|
|
106
107
|
getUserDepPath: ()=>getUserDepPath,
|
|
107
108
|
isString: ()=>isString
|
|
108
109
|
});
|
|
109
|
-
let core_namespaceObject = require("@rspack/core"),
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
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`;
|
|
116
|
-
return output;
|
|
110
|
+
let core_namespaceObject = require("@rspack/core"), isCIEnv = !!process.env.CI, isTTY = !!process.stdout?.isTTY, noColorEnv = process.env.NO_COLOR, forceColorEnv = process.env.FORCE_COLOR, disableColor = isCIEnv || !isTTY || noColorEnv && '0' !== noColorEnv || '0' === forceColorEnv, ANSI_SGR_RE = /\x1b\[[0-9;]*m/g, ANSI_OPEN_RE = /\x1b\[([0-9;]+)m/g, hexToAnsiOpen = (hex)=>{
|
|
111
|
+
let r, g, b, value = (hex || '').trim().replace(/^#/, '');
|
|
112
|
+
if (/^[0-9a-fA-F]{3}$/.test(value)) r = Number.parseInt(value[0] + value[0], 16), g = Number.parseInt(value[1] + value[1], 16), b = Number.parseInt(value[2] + value[2], 16);
|
|
113
|
+
else {
|
|
114
|
+
if (!/^[0-9a-fA-F]{6}$/.test(value)) return '';
|
|
115
|
+
r = Number.parseInt(value.slice(0, 2), 16), g = Number.parseInt(value.slice(2, 4), 16), b = Number.parseInt(value.slice(4, 6), 16);
|
|
117
116
|
}
|
|
118
|
-
|
|
117
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
118
|
+
}, hexColor = (hex)=>{
|
|
119
|
+
if (disableColor) return (input)=>String(input);
|
|
120
|
+
let open = hexToAnsiOpen(hex);
|
|
121
|
+
return open ? (input)=>`${open}${input}\x1b[39m` : (input)=>String(input);
|
|
122
|
+
}, ansi = (open, close)=>(input)=>disableColor ? String(input) : `${open}${input}${close}`, COLOR_HEX_brand = '#b39aff', COLOR_HEX_red = '#F38BA8', COLOR_HEX_green = '#A6E3A1', COLOR_HEX_yellow = '#F9E2AF', COLOR_HEX_blue = '#89B4FA', COLOR_HEX_magenta = '#CBA6F7', COLOR_HEX_cyan = '#89DCEB', COLOR_HEX_gray = '#6C7086', CODE_TO_OPEN = Object.fromEntries(Object.entries({
|
|
123
|
+
31: COLOR_HEX_red,
|
|
124
|
+
32: COLOR_HEX_green,
|
|
125
|
+
33: COLOR_HEX_yellow,
|
|
126
|
+
34: COLOR_HEX_blue,
|
|
127
|
+
35: COLOR_HEX_magenta,
|
|
128
|
+
36: COLOR_HEX_cyan,
|
|
129
|
+
90: COLOR_HEX_gray
|
|
130
|
+
}).map(([code, hex])=>[
|
|
131
|
+
code,
|
|
132
|
+
hexToAnsiOpen(hex)
|
|
133
|
+
])), colors = {
|
|
134
|
+
brand: hexColor(COLOR_HEX_brand),
|
|
135
|
+
red: hexColor(COLOR_HEX_red),
|
|
136
|
+
green: hexColor(COLOR_HEX_green),
|
|
137
|
+
yellow: hexColor(COLOR_HEX_yellow),
|
|
138
|
+
blue: hexColor(COLOR_HEX_blue),
|
|
139
|
+
magenta: hexColor(COLOR_HEX_magenta),
|
|
140
|
+
cyan: hexColor(COLOR_HEX_cyan),
|
|
141
|
+
gray: hexColor(COLOR_HEX_gray),
|
|
142
|
+
bold: ansi('\x1b[1m', '\x1b[22m'),
|
|
143
|
+
dim: ansi('\x1b[2m', '\x1b[22m')
|
|
144
|
+
};
|
|
145
|
+
function convertBasicAnsiColors(input) {
|
|
146
|
+
let text = String(input ?? '');
|
|
147
|
+
return text ? disableColor ? text.replace(ANSI_SGR_RE, '') : text.replace(ANSI_OPEN_RE, (substring, params)=>{
|
|
148
|
+
let tokens = params.split(';').filter(Boolean), colorToken = tokens.find((t)=>t in CODE_TO_OPEN);
|
|
149
|
+
if (!colorToken) return substring;
|
|
150
|
+
let open = CODE_TO_OPEN[colorToken];
|
|
151
|
+
if (!open) return substring;
|
|
152
|
+
let styleTokens = tokens.filter((t)=>t !== colorToken), styleSeq = styleTokens.length ? `\x1b[${styleTokens.join(';')}m` : '';
|
|
153
|
+
return `${styleSeq}${open}`;
|
|
154
|
+
}) : '';
|
|
155
|
+
}
|
|
156
|
+
let restartCleaners = [], addRestartCleaner = (...cleaners)=>{
|
|
119
157
|
restartCleaners.push(...cleaners);
|
|
120
158
|
}, cleanUpBeforeRestart = async ()=>{
|
|
121
159
|
await Promise.all(restartCleaners.map((cleaner)=>cleaner())), restartCleaners.length = 0;
|
|
@@ -378,7 +416,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
378
416
|
}
|
|
379
417
|
}
|
|
380
418
|
}
|
|
381
|
-
].filter(Boolean), colorPrefix = colors.
|
|
419
|
+
].filter(Boolean), colorPrefix = colors.brand(colors.dim('➜'));
|
|
382
420
|
help && console.log(!0 === help ? ` ${colorPrefix} ${colors.dim('press')} ${colors.bold('h + enter')} ${colors.dim('to show help')}` : ` ${colorPrefix} ${help}`);
|
|
383
421
|
let { createInterface } = await import("node:readline"), rl = createInterface({
|
|
384
422
|
input: process.stdin
|
|
@@ -723,7 +761,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
723
761
|
apply(compiler) {
|
|
724
762
|
let meta = JSON.stringify({
|
|
725
763
|
name: jsMinify_PLUGIN_NAME,
|
|
726
|
-
version: "3.
|
|
764
|
+
version: "3.4.1",
|
|
727
765
|
options: this.minifyOptions
|
|
728
766
|
});
|
|
729
767
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -977,7 +1015,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
977
1015
|
logger_logger.debug(`${colors.cyan(packageName)}: ${colors.yellow(count)} modules`);
|
|
978
1016
|
});
|
|
979
1017
|
}
|
|
980
|
-
isDebug() || logger_logger.clear(), console.log(colors.dim(getTime()), colors.cyan(
|
|
1018
|
+
isDebug() || logger_logger.clear(), console.log(colors.dim(getTime()), colors.cyan(`[${global.__unpack_caller_name}]`), colors.brand(utils_isDevServer() ? 'hmr update' : 'build'), `${colors.dim(fileInfo)}${sameCount > 1 ? ` ${colors.yellow(`(x${sameCount})`)}` : ''}`, isDebug() ? colors.dim(`| ${prettyTime(getCompileTime(stats))} (${stats.compilation.modules.size} modules)`) : '');
|
|
981
1019
|
}
|
|
982
1020
|
}
|
|
983
1021
|
let progress_PLUGIN_NAME = 'ProgressPlugin';
|
|
@@ -1036,7 +1074,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1036
1074
|
count > 0 && console.log(`Found ${colors.red(colors.bold(`${count} ${1 === count ? 'error' : 'errors'}`))}`);
|
|
1037
1075
|
},
|
|
1038
1076
|
error (message) {
|
|
1039
|
-
message.includes('RpcExitError') || message.includes('out of memory') || console.log(message.replace(/ERROR/g, 'Type Error'));
|
|
1077
|
+
message.includes('RpcExitError') || message.includes('out of memory') || console.log(convertBasicAnsiColors(message.replace(/ERROR/g, 'Type Error')));
|
|
1040
1078
|
}
|
|
1041
1079
|
}
|
|
1042
1080
|
})), config;
|
|
@@ -1908,7 +1946,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1908
1946
|
req.headers.accept?.includes('html') && (req.url = '/index.html'), next();
|
|
1909
1947
|
}), middlewares.unshift(core_namespaceObject.experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1910
1948
|
let server = new dev_server_namespaceObject.RspackDevServer(devServerOptions, compiler);
|
|
1911
|
-
await server.start(), logger_logger.greet(` ${colors.
|
|
1949
|
+
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.4.1`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - global.__unpack_start_time))} ${colors.dim('ms')}\n`), printAddressUrls(port, unpackConfig.server?.host), addRestartCleaner(()=>server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())));
|
|
1912
1950
|
let open = unpackConfig.server?.open, url = isString(open) ? open : `http://localhost:${port}`;
|
|
1913
1951
|
open && openBrowser(url), setupCliShortcuts({
|
|
1914
1952
|
openPage: async ()=>{
|
|
@@ -1931,7 +1969,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1931
1969
|
function printAddressUrls(port, host) {
|
|
1932
1970
|
let addressUrls = getAddressUrls({
|
|
1933
1971
|
port
|
|
1934
|
-
}), colorPrefix = colors.
|
|
1972
|
+
}), colorPrefix = colors.brand('➜');
|
|
1935
1973
|
addressUrls.forEach((addr, index)=>{
|
|
1936
1974
|
let url;
|
|
1937
1975
|
if (!host && 0 !== index) {
|
|
@@ -1981,7 +2019,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1981
2019
|
...mergeConfig(defaultConfig, config),
|
|
1982
2020
|
_context: {
|
|
1983
2021
|
callerName,
|
|
1984
|
-
version: "3.
|
|
2022
|
+
version: "3.4.1"
|
|
1985
2023
|
}
|
|
1986
2024
|
};
|
|
1987
2025
|
};
|
|
@@ -1989,7 +2027,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1989
2027
|
build: async ({ watch } = {})=>{
|
|
1990
2028
|
setNodeEnv(watch ? 'development' : 'production');
|
|
1991
2029
|
let config = resolveConfig();
|
|
1992
|
-
console.log(colors.
|
|
2030
|
+
console.log(colors.brand(`${callerName} v3.4.1`), colors.cyan(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
|
|
1993
2031
|
},
|
|
1994
2032
|
dev: async ()=>{
|
|
1995
2033
|
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
|
|
@@ -2016,7 +2054,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2016
2054
|
...options
|
|
2017
2055
|
});
|
|
2018
2056
|
}
|
|
2019
|
-
})(), exports.CSS_MODULES_LOCAL_IDENT_NAME = __webpack_exports__.CSS_MODULES_LOCAL_IDENT_NAME, exports.CSS_MODULES_REGEX = __webpack_exports__.CSS_MODULES_REGEX, exports.CSS_NAMED_EXPORT = __webpack_exports__.CSS_NAMED_EXPORT, exports.DEFAULT_DEV_HOST = __webpack_exports__.DEFAULT_DEV_HOST, exports.DEV_DEFAULT_FILENAME = __webpack_exports__.DEV_DEFAULT_FILENAME, exports.EXPORT_LOCALS_CONVENTION = __webpack_exports__.EXPORT_LOCALS_CONVENTION, exports.LogColor = __webpack_exports__.LogColor, exports.NODE_MODULES_REGEX = __webpack_exports__.NODE_MODULES_REGEX, exports.PROD_DEFAULT_FILENAME = __webpack_exports__.PROD_DEFAULT_FILENAME, exports.TEMPLATE_CONTENT = __webpack_exports__.TEMPLATE_CONTENT, exports.TEMP_DIR = __webpack_exports__.TEMP_DIR, exports.THREAD_OPTIONS = __webpack_exports__.THREAD_OPTIONS, exports.addRestartCleaner = __webpack_exports__.addRestartCleaner, exports.cleanUpBeforeRestart = __webpack_exports__.cleanUpBeforeRestart, exports.clearLine = __webpack_exports__.clearLine, exports.colors = __webpack_exports__.colors, exports.createChokidar = __webpack_exports__.createChokidar, exports.createUnpack = __webpack_exports__.createUnpack, exports.currentDevUnpackConfig = __webpack_exports__.currentDevUnpackConfig, exports.debounce = __webpack_exports__.debounce, exports.defineConfig = __webpack_exports__.defineConfig, exports.esVersionToBrowserslist = __webpack_exports__.esVersionToBrowserslist, exports.findExists = __webpack_exports__.findExists, exports.getAddressUrls = __webpack_exports__.getAddressUrls, exports.getCompiledPkgPath = __webpack_exports__.getCompiledPkgPath, exports.getIpv4Interfaces = __webpack_exports__.getIpv4Interfaces, exports.getNodeEnv = __webpack_exports__.getNodeEnv, exports.getPathInJs = __webpack_exports__.getPathInJs, exports.getPort = __webpack_exports__.getPort, exports.getTime = __webpack_exports__.getTime, exports.getUserDepPath = __webpack_exports__.getUserDepPath, exports.getUserDepVersion = __webpack_exports__.getUserDepVersion, exports.getValueByPath = __webpack_exports__.getValueByPath, exports.isBoolean = __webpack_exports__.isBoolean, exports.isCI = __webpack_exports__.isCI, exports.isCSSModules = __webpack_exports__.isCSSModules, exports.isDebug = __webpack_exports__.isDebug, exports.isDev = __webpack_exports__.isDev, exports.isDevServer = __webpack_exports__.isDevServer, exports.isEmptyDir = __webpack_exports__.isEmptyDir, exports.isFileExists = __webpack_exports__.isFileExists, exports.isFileSync = __webpack_exports__.isFileSync, exports.isFunction = __webpack_exports__.isFunction, exports.isNodeVersionAtLeast = __webpack_exports__.isNodeVersionAtLeast, exports.isObject = __webpack_exports__.isObject, exports.isPlainObject = __webpack_exports__.isPlainObject, exports.isProd = __webpack_exports__.isProd, exports.isRegExp = __webpack_exports__.isRegExp, exports.isString = __webpack_exports__.isString, exports.isUndefined = __webpack_exports__.isUndefined, exports.isWatch = __webpack_exports__.isWatch, exports.isWin = __webpack_exports__.isWin, exports.launchEditor = __webpack_exports__.launchEditor, exports.loadConfig = __webpack_exports__.loadConfig, exports.logUpdate = __webpack_exports__.logUpdate, exports.logger = __webpack_exports__.logger, exports.mergeConfig = __webpack_exports__.mergeConfig, exports.pathExists = __webpack_exports__.pathExists, exports.prettyTime = __webpack_exports__.prettyTime, exports.removeDir = __webpack_exports__.removeDir, exports.resolveConfigPath = __webpack_exports__.resolveConfigPath, exports.rspack = __webpack_exports__.rspack, exports.setCurrentDevUnpackConfig = __webpack_exports__.setCurrentDevUnpackConfig, exports.setDevServer = __webpack_exports__.setDevServer, exports.setNodeEnv = __webpack_exports__.setNodeEnv, exports.setValueByPath = __webpack_exports__.setValueByPath, exports.setupCliShortcuts = __webpack_exports__.setupCliShortcuts, exports.trackPerformance = __webpack_exports__.trackPerformance, __webpack_exports__)-1 === [
|
|
2057
|
+
})(), exports.CSS_MODULES_LOCAL_IDENT_NAME = __webpack_exports__.CSS_MODULES_LOCAL_IDENT_NAME, exports.CSS_MODULES_REGEX = __webpack_exports__.CSS_MODULES_REGEX, exports.CSS_NAMED_EXPORT = __webpack_exports__.CSS_NAMED_EXPORT, exports.DEFAULT_DEV_HOST = __webpack_exports__.DEFAULT_DEV_HOST, exports.DEV_DEFAULT_FILENAME = __webpack_exports__.DEV_DEFAULT_FILENAME, exports.EXPORT_LOCALS_CONVENTION = __webpack_exports__.EXPORT_LOCALS_CONVENTION, exports.LogColor = __webpack_exports__.LogColor, exports.NODE_MODULES_REGEX = __webpack_exports__.NODE_MODULES_REGEX, exports.PROD_DEFAULT_FILENAME = __webpack_exports__.PROD_DEFAULT_FILENAME, exports.TEMPLATE_CONTENT = __webpack_exports__.TEMPLATE_CONTENT, exports.TEMP_DIR = __webpack_exports__.TEMP_DIR, exports.THREAD_OPTIONS = __webpack_exports__.THREAD_OPTIONS, exports.addRestartCleaner = __webpack_exports__.addRestartCleaner, exports.cleanUpBeforeRestart = __webpack_exports__.cleanUpBeforeRestart, exports.clearLine = __webpack_exports__.clearLine, exports.colors = __webpack_exports__.colors, exports.convertBasicAnsiColors = __webpack_exports__.convertBasicAnsiColors, exports.createChokidar = __webpack_exports__.createChokidar, exports.createUnpack = __webpack_exports__.createUnpack, exports.currentDevUnpackConfig = __webpack_exports__.currentDevUnpackConfig, exports.debounce = __webpack_exports__.debounce, exports.defineConfig = __webpack_exports__.defineConfig, exports.esVersionToBrowserslist = __webpack_exports__.esVersionToBrowserslist, exports.findExists = __webpack_exports__.findExists, exports.getAddressUrls = __webpack_exports__.getAddressUrls, exports.getCompiledPkgPath = __webpack_exports__.getCompiledPkgPath, exports.getIpv4Interfaces = __webpack_exports__.getIpv4Interfaces, exports.getNodeEnv = __webpack_exports__.getNodeEnv, exports.getPathInJs = __webpack_exports__.getPathInJs, exports.getPort = __webpack_exports__.getPort, exports.getTime = __webpack_exports__.getTime, exports.getUserDepPath = __webpack_exports__.getUserDepPath, exports.getUserDepVersion = __webpack_exports__.getUserDepVersion, exports.getValueByPath = __webpack_exports__.getValueByPath, exports.isBoolean = __webpack_exports__.isBoolean, exports.isCI = __webpack_exports__.isCI, exports.isCSSModules = __webpack_exports__.isCSSModules, exports.isDebug = __webpack_exports__.isDebug, exports.isDev = __webpack_exports__.isDev, exports.isDevServer = __webpack_exports__.isDevServer, exports.isEmptyDir = __webpack_exports__.isEmptyDir, exports.isFileExists = __webpack_exports__.isFileExists, exports.isFileSync = __webpack_exports__.isFileSync, exports.isFunction = __webpack_exports__.isFunction, exports.isNodeVersionAtLeast = __webpack_exports__.isNodeVersionAtLeast, exports.isObject = __webpack_exports__.isObject, exports.isPlainObject = __webpack_exports__.isPlainObject, exports.isProd = __webpack_exports__.isProd, exports.isRegExp = __webpack_exports__.isRegExp, exports.isString = __webpack_exports__.isString, exports.isUndefined = __webpack_exports__.isUndefined, exports.isWatch = __webpack_exports__.isWatch, exports.isWin = __webpack_exports__.isWin, exports.launchEditor = __webpack_exports__.launchEditor, exports.loadConfig = __webpack_exports__.loadConfig, exports.logUpdate = __webpack_exports__.logUpdate, exports.logger = __webpack_exports__.logger, exports.mergeConfig = __webpack_exports__.mergeConfig, exports.pathExists = __webpack_exports__.pathExists, exports.prettyTime = __webpack_exports__.prettyTime, exports.removeDir = __webpack_exports__.removeDir, exports.resolveConfigPath = __webpack_exports__.resolveConfigPath, exports.rspack = __webpack_exports__.rspack, exports.setCurrentDevUnpackConfig = __webpack_exports__.setCurrentDevUnpackConfig, exports.setDevServer = __webpack_exports__.setDevServer, exports.setNodeEnv = __webpack_exports__.setNodeEnv, exports.setValueByPath = __webpack_exports__.setValueByPath, exports.setupCliShortcuts = __webpack_exports__.setupCliShortcuts, exports.trackPerformance = __webpack_exports__.trackPerformance, __webpack_exports__)-1 === [
|
|
2020
2058
|
"CSS_MODULES_LOCAL_IDENT_NAME",
|
|
2021
2059
|
"CSS_MODULES_REGEX",
|
|
2022
2060
|
"CSS_NAMED_EXPORT",
|
|
@@ -2033,6 +2071,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2033
2071
|
"cleanUpBeforeRestart",
|
|
2034
2072
|
"clearLine",
|
|
2035
2073
|
"colors",
|
|
2074
|
+
"convertBasicAnsiColors",
|
|
2036
2075
|
"createChokidar",
|
|
2037
2076
|
"createUnpack",
|
|
2038
2077
|
"currentDevUnpackConfig",
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,6 @@ let require = __rslib_shim_module__.createRequire(import.meta.url);
|
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_launch_editor_index_js_29002383__ from "../compiled/launch-editor/index.js";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_merge_index_js_efd91626__ from "../compiled/webpack-merge/index.js";
|
|
6
6
|
import { experiments, rspack } from "@rspack/core";
|
|
7
|
-
import picocolors from "picocolors";
|
|
8
7
|
import node_readline from "node:readline";
|
|
9
8
|
import node_fs from "node:fs";
|
|
10
9
|
import node_net from "node:net";
|
|
@@ -35,16 +34,53 @@ function __webpack_require__(moduleId) {
|
|
|
35
34
|
};
|
|
36
35
|
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
37
36
|
}
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
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`;
|
|
45
|
-
return output;
|
|
37
|
+
let isCIEnv = !!process.env.CI, isTTY = !!process.stdout?.isTTY, noColorEnv = process.env.NO_COLOR, forceColorEnv = process.env.FORCE_COLOR, disableColor = isCIEnv || !isTTY || noColorEnv && '0' !== noColorEnv || '0' === forceColorEnv, ANSI_SGR_RE = /\x1b\[[0-9;]*m/g, ANSI_OPEN_RE = /\x1b\[([0-9;]+)m/g, hexToAnsiOpen = (hex)=>{
|
|
38
|
+
let r, g, b, value = (hex || '').trim().replace(/^#/, '');
|
|
39
|
+
if (/^[0-9a-fA-F]{3}$/.test(value)) r = Number.parseInt(value[0] + value[0], 16), g = Number.parseInt(value[1] + value[1], 16), b = Number.parseInt(value[2] + value[2], 16);
|
|
40
|
+
else {
|
|
41
|
+
if (!/^[0-9a-fA-F]{6}$/.test(value)) return '';
|
|
42
|
+
r = Number.parseInt(value.slice(0, 2), 16), g = Number.parseInt(value.slice(2, 4), 16), b = Number.parseInt(value.slice(4, 6), 16);
|
|
46
43
|
}
|
|
47
|
-
|
|
44
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
45
|
+
}, hexColor = (hex)=>{
|
|
46
|
+
if (disableColor) return (input)=>String(input);
|
|
47
|
+
let open = hexToAnsiOpen(hex);
|
|
48
|
+
return open ? (input)=>`${open}${input}\x1b[39m` : (input)=>String(input);
|
|
49
|
+
}, ansi = (open, close)=>(input)=>disableColor ? String(input) : `${open}${input}${close}`, COLOR_HEX_red = '#F38BA8', COLOR_HEX_green = '#A6E3A1', COLOR_HEX_yellow = '#F9E2AF', COLOR_HEX_blue = '#89B4FA', COLOR_HEX_magenta = '#CBA6F7', COLOR_HEX_cyan = '#89DCEB', COLOR_HEX_gray = '#6C7086', CODE_TO_OPEN = Object.fromEntries(Object.entries({
|
|
50
|
+
31: COLOR_HEX_red,
|
|
51
|
+
32: COLOR_HEX_green,
|
|
52
|
+
33: COLOR_HEX_yellow,
|
|
53
|
+
34: COLOR_HEX_blue,
|
|
54
|
+
35: COLOR_HEX_magenta,
|
|
55
|
+
36: COLOR_HEX_cyan,
|
|
56
|
+
90: COLOR_HEX_gray
|
|
57
|
+
}).map(([code, hex])=>[
|
|
58
|
+
code,
|
|
59
|
+
hexToAnsiOpen(hex)
|
|
60
|
+
])), colors = {
|
|
61
|
+
brand: hexColor('#b39aff'),
|
|
62
|
+
red: hexColor(COLOR_HEX_red),
|
|
63
|
+
green: hexColor(COLOR_HEX_green),
|
|
64
|
+
yellow: hexColor(COLOR_HEX_yellow),
|
|
65
|
+
blue: hexColor(COLOR_HEX_blue),
|
|
66
|
+
magenta: hexColor(COLOR_HEX_magenta),
|
|
67
|
+
cyan: hexColor(COLOR_HEX_cyan),
|
|
68
|
+
gray: hexColor(COLOR_HEX_gray),
|
|
69
|
+
bold: ansi('\x1b[1m', '\x1b[22m'),
|
|
70
|
+
dim: ansi('\x1b[2m', '\x1b[22m')
|
|
71
|
+
};
|
|
72
|
+
function convertBasicAnsiColors(input) {
|
|
73
|
+
let text = String(input ?? '');
|
|
74
|
+
return text ? disableColor ? text.replace(ANSI_SGR_RE, '') : text.replace(ANSI_OPEN_RE, (substring, params)=>{
|
|
75
|
+
let tokens = params.split(';').filter(Boolean), colorToken = tokens.find((t)=>t in CODE_TO_OPEN);
|
|
76
|
+
if (!colorToken) return substring;
|
|
77
|
+
let open = CODE_TO_OPEN[colorToken];
|
|
78
|
+
if (!open) return substring;
|
|
79
|
+
let styleTokens = tokens.filter((t)=>t !== colorToken), styleSeq = styleTokens.length ? `\x1b[${styleTokens.join(';')}m` : '';
|
|
80
|
+
return `${styleSeq}${open}`;
|
|
81
|
+
}) : '';
|
|
82
|
+
}
|
|
83
|
+
let restartCleaners = [], addRestartCleaner = (...cleaners)=>{
|
|
48
84
|
restartCleaners.push(...cleaners);
|
|
49
85
|
}, cleanUpBeforeRestart = async ()=>{
|
|
50
86
|
await Promise.all(restartCleaners.map((cleaner)=>cleaner())), restartCleaners.length = 0;
|
|
@@ -296,7 +332,7 @@ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls,
|
|
|
296
332
|
}
|
|
297
333
|
}
|
|
298
334
|
}
|
|
299
|
-
].filter(Boolean), colorPrefix = colors.
|
|
335
|
+
].filter(Boolean), colorPrefix = colors.brand(colors.dim('➜'));
|
|
300
336
|
help && console.log(!0 === help ? ` ${colorPrefix} ${colors.dim('press')} ${colors.bold('h + enter')} ${colors.dim('to show help')}` : ` ${colorPrefix} ${help}`);
|
|
301
337
|
let { createInterface } = await import("node:readline"), rl = createInterface({
|
|
302
338
|
input: process.stdin
|
|
@@ -639,7 +675,7 @@ class JsMinifyPlugin {
|
|
|
639
675
|
apply(compiler) {
|
|
640
676
|
let meta = JSON.stringify({
|
|
641
677
|
name: jsMinify_PLUGIN_NAME,
|
|
642
|
-
version: "3.
|
|
678
|
+
version: "3.4.1",
|
|
643
679
|
options: this.minifyOptions
|
|
644
680
|
});
|
|
645
681
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -890,7 +926,7 @@ async function compileDone(compiler, stats) {
|
|
|
890
926
|
logger_logger.debug(`${colors.cyan(packageName)}: ${colors.yellow(count)} modules`);
|
|
891
927
|
});
|
|
892
928
|
}
|
|
893
|
-
isDebug() || logger_logger.clear(), console.log(colors.dim(getTime()), colors.cyan(
|
|
929
|
+
isDebug() || logger_logger.clear(), console.log(colors.dim(getTime()), colors.cyan(`[${global.__unpack_caller_name}]`), colors.brand(utils_isDevServer() ? 'hmr update' : 'build'), `${colors.dim(fileInfo)}${sameCount > 1 ? ` ${colors.yellow(`(x${sameCount})`)}` : ''}`, isDebug() ? colors.dim(`| ${prettyTime(getCompileTime(stats))} (${stats.compilation.modules.size} modules)`) : '');
|
|
894
930
|
}
|
|
895
931
|
}
|
|
896
932
|
let progress_PLUGIN_NAME = 'ProgressPlugin';
|
|
@@ -948,7 +984,7 @@ async function applyTypeCheckConfig({ config, unpackConfig }) {
|
|
|
948
984
|
count > 0 && console.log(`Found ${colors.red(colors.bold(`${count} ${1 === count ? 'error' : 'errors'}`))}`);
|
|
949
985
|
},
|
|
950
986
|
error (message) {
|
|
951
|
-
message.includes('RpcExitError') || message.includes('out of memory') || console.log(message.replace(/ERROR/g, 'Type Error'));
|
|
987
|
+
message.includes('RpcExitError') || message.includes('out of memory') || console.log(convertBasicAnsiColors(message.replace(/ERROR/g, 'Type Error')));
|
|
952
988
|
}
|
|
953
989
|
}
|
|
954
990
|
})), config;
|
|
@@ -1818,7 +1854,7 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1818
1854
|
req.headers.accept?.includes('html') && (req.url = '/index.html'), next();
|
|
1819
1855
|
}), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1820
1856
|
let server = new RspackDevServer(devServerOptions, compiler);
|
|
1821
|
-
await server.start(), logger_logger.greet(` ${colors.
|
|
1857
|
+
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.4.1`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - global.__unpack_start_time))} ${colors.dim('ms')}\n`), printAddressUrls(port, unpackConfig.server?.host), addRestartCleaner(()=>server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())));
|
|
1822
1858
|
let open = unpackConfig.server?.open, url = isString(open) ? open : `http://localhost:${port}`;
|
|
1823
1859
|
open && openBrowser(url), setupCliShortcuts({
|
|
1824
1860
|
openPage: async ()=>{
|
|
@@ -1841,7 +1877,7 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1841
1877
|
function printAddressUrls(port, host) {
|
|
1842
1878
|
let addressUrls = getAddressUrls({
|
|
1843
1879
|
port
|
|
1844
|
-
}), colorPrefix = colors.
|
|
1880
|
+
}), colorPrefix = colors.brand('➜');
|
|
1845
1881
|
addressUrls.forEach((addr, index)=>{
|
|
1846
1882
|
let url;
|
|
1847
1883
|
if (!host && 0 !== index) {
|
|
@@ -1891,7 +1927,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
|
1891
1927
|
...mergeConfig(defaultConfig, config),
|
|
1892
1928
|
_context: {
|
|
1893
1929
|
callerName,
|
|
1894
|
-
version: "3.
|
|
1930
|
+
version: "3.4.1"
|
|
1895
1931
|
}
|
|
1896
1932
|
};
|
|
1897
1933
|
};
|
|
@@ -1899,7 +1935,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
|
1899
1935
|
build: async ({ watch } = {})=>{
|
|
1900
1936
|
setNodeEnv(watch ? 'development' : 'production');
|
|
1901
1937
|
let config = resolveConfig();
|
|
1902
|
-
console.log(colors.
|
|
1938
|
+
console.log(colors.brand(`${callerName} v3.4.1`), colors.cyan(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
|
|
1903
1939
|
},
|
|
1904
1940
|
dev: async ()=>{
|
|
1905
1941
|
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
|
|
@@ -1924,4 +1960,4 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
|
|
|
1924
1960
|
var __webpack_exports__CSS_NAMED_EXPORT = !1;
|
|
1925
1961
|
import { fileURLToPath as __webpack_fileURLToPath__, pathToFileURL } from "node:url";
|
|
1926
1962
|
import node_path, { dirname as __webpack_dirname__, join, sep } from "node:path";
|
|
1927
|
-
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, launchEditor, 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 };
|
|
1963
|
+
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, convertBasicAnsiColors, 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, launchEditor, 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 };
|
|
@@ -5,7 +5,6 @@ import node_path from "node:path";
|
|
|
5
5
|
import "node:net";
|
|
6
6
|
import "node:os";
|
|
7
7
|
import "portfinder";
|
|
8
|
-
import picocolors from "picocolors";
|
|
9
8
|
var __webpack_modules__ = {
|
|
10
9
|
"compiled/launch-editor": function(module) {
|
|
11
10
|
module.exports = __WEBPACK_EXTERNAL_MODULE__compiled_launch_editor_index_js_29002383__;
|
|
@@ -22,17 +21,31 @@ function __webpack_require__(moduleId) {
|
|
|
22
21
|
};
|
|
23
22
|
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
24
23
|
}
|
|
25
|
-
let CSS_MODULES_REGEX = /\.module\.\w+$/i, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
], steps = chars.filter(isWord).length, r = 97, g = 193, b = 198, rStep = -49 / steps, gStep = -81 / steps, bStep = 0 / steps, output = '';
|
|
32
|
-
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`;
|
|
33
|
-
return output;
|
|
24
|
+
let CSS_MODULES_REGEX = /\.module\.\w+$/i, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, isCIEnv = !!process.env.CI, isTTY = !!process.stdout?.isTTY, noColorEnv = process.env.NO_COLOR, forceColorEnv = process.env.FORCE_COLOR, disableColor = isCIEnv || !isTTY || noColorEnv && '0' !== noColorEnv || '0' === forceColorEnv, hexToAnsiOpen = (hex)=>{
|
|
25
|
+
let r, g, b, value = (hex || '').trim().replace(/^#/, '');
|
|
26
|
+
if (/^[0-9a-fA-F]{3}$/.test(value)) r = Number.parseInt(value[0] + value[0], 16), g = Number.parseInt(value[1] + value[1], 16), b = Number.parseInt(value[2] + value[2], 16);
|
|
27
|
+
else {
|
|
28
|
+
if (!/^[0-9a-fA-F]{6}$/.test(value)) return '';
|
|
29
|
+
r = Number.parseInt(value.slice(0, 2), 16), g = Number.parseInt(value.slice(2, 4), 16), b = Number.parseInt(value.slice(4, 6), 16);
|
|
34
30
|
}
|
|
35
|
-
}
|
|
31
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
32
|
+
}, hexColor = (hex)=>{
|
|
33
|
+
if (disableColor) return (input)=>String(input);
|
|
34
|
+
let open = hexToAnsiOpen(hex);
|
|
35
|
+
return open ? (input)=>`${open}${input}\x1b[39m` : (input)=>String(input);
|
|
36
|
+
}, ansi = (open, close)=>(input)=>disableColor ? String(input) : `${open}${input}${close}`, COLOR_HEX_red = '#F38BA8', COLOR_HEX_green = '#A6E3A1', COLOR_HEX_yellow = '#F9E2AF', COLOR_HEX_blue = '#89B4FA', COLOR_HEX_magenta = '#CBA6F7', COLOR_HEX_cyan = '#89DCEB', COLOR_HEX_gray = '#6C7086';
|
|
37
|
+
Object.fromEntries(Object.entries({
|
|
38
|
+
31: COLOR_HEX_red,
|
|
39
|
+
32: COLOR_HEX_green,
|
|
40
|
+
33: COLOR_HEX_yellow,
|
|
41
|
+
34: COLOR_HEX_blue,
|
|
42
|
+
35: COLOR_HEX_magenta,
|
|
43
|
+
36: COLOR_HEX_cyan,
|
|
44
|
+
90: COLOR_HEX_gray
|
|
45
|
+
}).map(([code, hex])=>[
|
|
46
|
+
code,
|
|
47
|
+
hexToAnsiOpen(hex)
|
|
48
|
+
])), hexColor('#b39aff'), hexColor(COLOR_HEX_red), hexColor(COLOR_HEX_green), hexColor(COLOR_HEX_yellow), hexColor(COLOR_HEX_blue), hexColor(COLOR_HEX_magenta), hexColor(COLOR_HEX_cyan), hexColor(COLOR_HEX_gray), ansi('\x1b[1m', '\x1b[22m'), ansi('\x1b[2m', '\x1b[22m');
|
|
36
49
|
let { merge } = __webpack_require__("compiled/webpack-merge");
|
|
37
50
|
__webpack_require__("compiled/launch-editor");
|
|
38
51
|
let enforceLFLineSeparators = (text)=>text ? text.replace(/\r\n/g, '\n') : text;
|
package/dist-types/colors.d.ts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type Input = string | number;
|
|
2
|
+
type Formatter = (input: Input) => string;
|
|
3
|
+
type Colors = {
|
|
4
|
+
red: Formatter;
|
|
5
|
+
green: Formatter;
|
|
6
|
+
yellow: Formatter;
|
|
7
|
+
blue: Formatter;
|
|
8
|
+
magenta: Formatter;
|
|
9
|
+
cyan: Formatter;
|
|
10
|
+
gray: Formatter;
|
|
11
|
+
brand: Formatter;
|
|
12
|
+
bold: Formatter;
|
|
13
|
+
dim: Formatter;
|
|
5
14
|
};
|
|
15
|
+
export declare const colors: Colors;
|
|
16
|
+
/**
|
|
17
|
+
* Convert legacy 8-color ANSI sequences in the given string
|
|
18
|
+
* to our 24-bit color palette while preserving the foreground close (FG_RESET).
|
|
19
|
+
*
|
|
20
|
+
* Legacy opens handled:
|
|
21
|
+
* - 31 red
|
|
22
|
+
* - 32 green
|
|
23
|
+
* - 33 yellow
|
|
24
|
+
* - 34 blue
|
|
25
|
+
* - 35 magenta
|
|
26
|
+
* - 36 cyan
|
|
27
|
+
* - 90 gray
|
|
28
|
+
*/
|
|
29
|
+
export declare function convertBasicAnsiColors(input: string): string;
|
|
30
|
+
export {};
|
|
6
31
|
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAC5B,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAA;AACzC,KAAK,MAAM,GAAG;IACZ,GAAG,EAAE,SAAS,CAAA;IACd,KAAK,EAAE,SAAS,CAAA;IAChB,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,SAAS,CAAA;IAClB,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,EAAE,SAAS,CAAA;IAChB,IAAI,EAAE,SAAS,CAAA;IACf,GAAG,EAAE,SAAS,CAAA;CACf,CAAA;AA+ED,eAAO,MAAM,MAAM,EAAE,MAWpB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoB5D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpackjs/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"description": "An Rspack-based build tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"express": "5.1.0",
|
|
50
50
|
"jiti": "2.6.1",
|
|
51
51
|
"oxc-minify": "0.96.0",
|
|
52
|
-
"picocolors": "1.1.1",
|
|
53
52
|
"portfinder": "1.0.38",
|
|
54
53
|
"postcss": "8.5.6",
|
|
55
54
|
"thread-loader": "4.0.4",
|