@unpackjs/core 3.4.0 → 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 +51 -25
- package/dist/index.js +47 -21
- package/dist/typedCssModulesLoader.mjs +20 -6
- package/dist-types/colors.d.ts +14 -1
- package/dist-types/colors.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -52,7 +52,6 @@ for(var __webpack_i__ in (()=>{
|
|
|
52
52
|
isWatch: ()=>isWatch,
|
|
53
53
|
DEFAULT_DEV_HOST: ()=>DEFAULT_DEV_HOST,
|
|
54
54
|
isDev: ()=>isDev,
|
|
55
|
-
hexColor: ()=>hexColor,
|
|
56
55
|
isRegExp: ()=>isRegExp,
|
|
57
56
|
cleanUpBeforeRestart: ()=>cleanUpBeforeRestart,
|
|
58
57
|
currentDevUnpackConfig: ()=>currentDevUnpackConfig,
|
|
@@ -89,9 +88,10 @@ for(var __webpack_i__ in (()=>{
|
|
|
89
88
|
isWin: ()=>isWin,
|
|
90
89
|
prettyTime: ()=>prettyTime,
|
|
91
90
|
setupCliShortcuts: ()=>setupCliShortcuts,
|
|
92
|
-
|
|
91
|
+
convertBasicAnsiColors: ()=>convertBasicAnsiColors,
|
|
93
92
|
THREAD_OPTIONS: ()=>THREAD_OPTIONS,
|
|
94
93
|
createUnpack: ()=>createUnpack,
|
|
94
|
+
loadConfig: ()=>loadConfig,
|
|
95
95
|
setDevServer: ()=>setDevServer,
|
|
96
96
|
EXPORT_LOCALS_CONVENTION: ()=>EXPORT_LOCALS_CONVENTION,
|
|
97
97
|
isFileExists: ()=>isFileExists,
|
|
@@ -107,27 +107,53 @@ for(var __webpack_i__ in (()=>{
|
|
|
107
107
|
getUserDepPath: ()=>getUserDepPath,
|
|
108
108
|
isString: ()=>isString
|
|
109
109
|
});
|
|
110
|
-
let core_namespaceObject = require("@rspack/core"),
|
|
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
111
|
let r, g, b, value = (hex || '').trim().replace(/^#/, '');
|
|
112
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
113
|
else {
|
|
114
|
-
if (!/^[0-9a-fA-F]{6}$/.test(value)) return
|
|
114
|
+
if (!/^[0-9a-fA-F]{6}$/.test(value)) return '';
|
|
115
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);
|
|
116
116
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
},
|
|
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)=>{
|
|
131
157
|
restartCleaners.push(...cleaners);
|
|
132
158
|
}, cleanUpBeforeRestart = async ()=>{
|
|
133
159
|
await Promise.all(restartCleaners.map((cleaner)=>cleaner())), restartCleaners.length = 0;
|
|
@@ -735,7 +761,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
735
761
|
apply(compiler) {
|
|
736
762
|
let meta = JSON.stringify({
|
|
737
763
|
name: jsMinify_PLUGIN_NAME,
|
|
738
|
-
version: "3.4.
|
|
764
|
+
version: "3.4.1",
|
|
739
765
|
options: this.minifyOptions
|
|
740
766
|
});
|
|
741
767
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -1048,7 +1074,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1048
1074
|
count > 0 && console.log(`Found ${colors.red(colors.bold(`${count} ${1 === count ? 'error' : 'errors'}`))}`);
|
|
1049
1075
|
},
|
|
1050
1076
|
error (message) {
|
|
1051
|
-
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')));
|
|
1052
1078
|
}
|
|
1053
1079
|
}
|
|
1054
1080
|
})), config;
|
|
@@ -1920,7 +1946,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1920
1946
|
req.headers.accept?.includes('html') && (req.url = '/index.html'), next();
|
|
1921
1947
|
}), middlewares.unshift(core_namespaceObject.experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1922
1948
|
let server = new dev_server_namespaceObject.RspackDevServer(devServerOptions, compiler);
|
|
1923
|
-
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.4.
|
|
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())));
|
|
1924
1950
|
let open = unpackConfig.server?.open, url = isString(open) ? open : `http://localhost:${port}`;
|
|
1925
1951
|
open && openBrowser(url), setupCliShortcuts({
|
|
1926
1952
|
openPage: async ()=>{
|
|
@@ -1993,7 +2019,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1993
2019
|
...mergeConfig(defaultConfig, config),
|
|
1994
2020
|
_context: {
|
|
1995
2021
|
callerName,
|
|
1996
|
-
version: "3.4.
|
|
2022
|
+
version: "3.4.1"
|
|
1997
2023
|
}
|
|
1998
2024
|
};
|
|
1999
2025
|
};
|
|
@@ -2001,7 +2027,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2001
2027
|
build: async ({ watch } = {})=>{
|
|
2002
2028
|
setNodeEnv(watch ? 'development' : 'production');
|
|
2003
2029
|
let config = resolveConfig();
|
|
2004
|
-
console.log(colors.brand(`${callerName} v3.4.
|
|
2030
|
+
console.log(colors.brand(`${callerName} v3.4.1`), colors.cyan(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
|
|
2005
2031
|
},
|
|
2006
2032
|
dev: async ()=>{
|
|
2007
2033
|
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
|
|
@@ -2028,7 +2054,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2028
2054
|
...options
|
|
2029
2055
|
});
|
|
2030
2056
|
}
|
|
2031
|
-
})(), 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.
|
|
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 === [
|
|
2032
2058
|
"CSS_MODULES_LOCAL_IDENT_NAME",
|
|
2033
2059
|
"CSS_MODULES_REGEX",
|
|
2034
2060
|
"CSS_NAMED_EXPORT",
|
|
@@ -2045,6 +2071,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2045
2071
|
"cleanUpBeforeRestart",
|
|
2046
2072
|
"clearLine",
|
|
2047
2073
|
"colors",
|
|
2074
|
+
"convertBasicAnsiColors",
|
|
2048
2075
|
"createChokidar",
|
|
2049
2076
|
"createUnpack",
|
|
2050
2077
|
"currentDevUnpackConfig",
|
|
@@ -2062,7 +2089,6 @@ for(var __webpack_i__ in (()=>{
|
|
|
2062
2089
|
"getUserDepPath",
|
|
2063
2090
|
"getUserDepVersion",
|
|
2064
2091
|
"getValueByPath",
|
|
2065
|
-
"hexColor",
|
|
2066
2092
|
"isBoolean",
|
|
2067
2093
|
"isCI",
|
|
2068
2094
|
"isCSSModules",
|
package/dist/index.js
CHANGED
|
@@ -34,27 +34,53 @@ function __webpack_require__(moduleId) {
|
|
|
34
34
|
};
|
|
35
35
|
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
36
36
|
}
|
|
37
|
-
let
|
|
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
38
|
let r, g, b, value = (hex || '').trim().replace(/^#/, '');
|
|
39
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
40
|
else {
|
|
41
|
-
if (!/^[0-9a-fA-F]{6}$/.test(value)) return
|
|
41
|
+
if (!/^[0-9a-fA-F]{6}$/.test(value)) return '';
|
|
42
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);
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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 = {
|
|
47
61
|
brand: hexColor('#b39aff'),
|
|
48
|
-
red: hexColor(
|
|
49
|
-
green: hexColor(
|
|
50
|
-
yellow: hexColor(
|
|
51
|
-
blue: hexColor(
|
|
52
|
-
magenta: hexColor(
|
|
53
|
-
cyan: hexColor(
|
|
54
|
-
gray: hexColor(
|
|
55
|
-
bold: (
|
|
56
|
-
dim: (
|
|
57
|
-
}
|
|
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)=>{
|
|
58
84
|
restartCleaners.push(...cleaners);
|
|
59
85
|
}, cleanUpBeforeRestart = async ()=>{
|
|
60
86
|
await Promise.all(restartCleaners.map((cleaner)=>cleaner())), restartCleaners.length = 0;
|
|
@@ -649,7 +675,7 @@ class JsMinifyPlugin {
|
|
|
649
675
|
apply(compiler) {
|
|
650
676
|
let meta = JSON.stringify({
|
|
651
677
|
name: jsMinify_PLUGIN_NAME,
|
|
652
|
-
version: "3.4.
|
|
678
|
+
version: "3.4.1",
|
|
653
679
|
options: this.minifyOptions
|
|
654
680
|
});
|
|
655
681
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -958,7 +984,7 @@ async function applyTypeCheckConfig({ config, unpackConfig }) {
|
|
|
958
984
|
count > 0 && console.log(`Found ${colors.red(colors.bold(`${count} ${1 === count ? 'error' : 'errors'}`))}`);
|
|
959
985
|
},
|
|
960
986
|
error (message) {
|
|
961
|
-
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')));
|
|
962
988
|
}
|
|
963
989
|
}
|
|
964
990
|
})), config;
|
|
@@ -1828,7 +1854,7 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1828
1854
|
req.headers.accept?.includes('html') && (req.url = '/index.html'), next();
|
|
1829
1855
|
}), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1830
1856
|
let server = new RspackDevServer(devServerOptions, compiler);
|
|
1831
|
-
await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.4.
|
|
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())));
|
|
1832
1858
|
let open = unpackConfig.server?.open, url = isString(open) ? open : `http://localhost:${port}`;
|
|
1833
1859
|
open && openBrowser(url), setupCliShortcuts({
|
|
1834
1860
|
openPage: async ()=>{
|
|
@@ -1901,7 +1927,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
|
1901
1927
|
...mergeConfig(defaultConfig, config),
|
|
1902
1928
|
_context: {
|
|
1903
1929
|
callerName,
|
|
1904
|
-
version: "3.4.
|
|
1930
|
+
version: "3.4.1"
|
|
1905
1931
|
}
|
|
1906
1932
|
};
|
|
1907
1933
|
};
|
|
@@ -1909,7 +1935,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
|
1909
1935
|
build: async ({ watch } = {})=>{
|
|
1910
1936
|
setNodeEnv(watch ? 'development' : 'production');
|
|
1911
1937
|
let config = resolveConfig();
|
|
1912
|
-
console.log(colors.brand(`${callerName} v3.4.
|
|
1938
|
+
console.log(colors.brand(`${callerName} v3.4.1`), colors.cyan(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
|
|
1913
1939
|
},
|
|
1914
1940
|
dev: async ()=>{
|
|
1915
1941
|
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
|
|
@@ -1934,4 +1960,4 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
|
|
|
1934
1960
|
var __webpack_exports__CSS_NAMED_EXPORT = !1;
|
|
1935
1961
|
import { fileURLToPath as __webpack_fileURLToPath__, pathToFileURL } from "node:url";
|
|
1936
1962
|
import node_path, { dirname as __webpack_dirname__, join, sep } from "node:path";
|
|
1937
|
-
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,
|
|
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 };
|
|
@@ -21,17 +21,31 @@ function __webpack_require__(moduleId) {
|
|
|
21
21
|
};
|
|
22
22
|
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
23
23
|
}
|
|
24
|
-
let CSS_MODULES_REGEX = /\.module\.\w+$/i, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/,
|
|
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
25
|
let r, g, b, value = (hex || '').trim().replace(/^#/, '');
|
|
26
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
27
|
else {
|
|
28
|
-
if (!/^[0-9a-fA-F]{6}$/.test(value)) return
|
|
28
|
+
if (!/^[0-9a-fA-F]{6}$/.test(value)) return '';
|
|
29
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);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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');
|
|
35
49
|
let { merge } = __webpack_require__("compiled/webpack-merge");
|
|
36
50
|
__webpack_require__("compiled/launch-editor");
|
|
37
51
|
let enforceLFLineSeparators = (text)=>text ? text.replace(/\r\n/g, '\n') : text;
|
package/dist-types/colors.d.ts
CHANGED
|
@@ -12,7 +12,20 @@ type Colors = {
|
|
|
12
12
|
bold: Formatter;
|
|
13
13
|
dim: Formatter;
|
|
14
14
|
};
|
|
15
|
-
export declare const hexColor: (hex: string) => Formatter;
|
|
16
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;
|
|
17
30
|
export {};
|
|
18
31
|
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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"}
|