@unpackjs/core 3.4.0 → 3.4.2

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 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,
@@ -78,7 +77,7 @@ for(var __webpack_i__ in (()=>{
78
77
  getIpv4Interfaces: ()=>getIpv4Interfaces,
79
78
  getNodeEnv: ()=>getNodeEnv,
80
79
  getPort: ()=>getPort,
81
- isCI: ()=>isCI,
80
+ isCI: ()=>utils_isCI,
82
81
  logger: ()=>logger_logger,
83
82
  addRestartCleaner: ()=>addRestartCleaner,
84
83
  colors: ()=>colors,
@@ -89,9 +88,10 @@ for(var __webpack_i__ in (()=>{
89
88
  isWin: ()=>isWin,
90
89
  prettyTime: ()=>prettyTime,
91
90
  setupCliShortcuts: ()=>setupCliShortcuts,
92
- loadConfig: ()=>loadConfig,
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,73 @@ for(var __webpack_i__ in (()=>{
107
107
  getUserDepPath: ()=>getUserDepPath,
108
108
  isString: ()=>isString
109
109
  });
110
- let core_namespaceObject = require("@rspack/core"), hexColor = (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 (input)=>String(input);
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
- }
117
- let prefix = `\x1b[38;2;${r};${g};${b}m`;
118
- return (input)=>`${prefix}${input}\x1b[39m`;
119
- }, colors = {
120
- brand: hexColor('#b39aff'),
121
- red: hexColor('#F38BA8'),
122
- green: hexColor('#A6E3A1'),
123
- yellow: hexColor('#F9E2AF'),
124
- blue: hexColor('#89B4FA'),
125
- magenta: hexColor('#CBA6F7'),
126
- cyan: hexColor('#89DCEB'),
127
- gray: hexColor('#6C7086'),
128
- bold: (input)=>`\x1b[1m${input}\x1b[22m`,
129
- dim: (input)=>`\x1b[2m${input}\x1b[22m`
130
- }, restartCleaners = [], addRestartCleaner = (...cleaners)=>{
110
+ let core_namespaceObject = require("@rspack/core"), isCI = !!process.env.CI, isTTY = !!process.stdout?.isTTY, noColor = !!process.env.NO_COLOR, forceColor = !!process.env.FORCE_COLOR, disableColor = !1;
111
+ disableColor = !!noColor || !forceColor && (isCI || !isTTY);
112
+ let ANSI_SGR_RE = /\x1b\[[0-9;]*m/g, ANSI_OPEN_RE = /\x1b\[([0-9;]+)m/g, COLOR_HEX = {
113
+ brand: '#b39aff',
114
+ red: '#F38BA8',
115
+ green: '#A6E3A1',
116
+ yellow: '#F9E2AF',
117
+ blue: '#89B4FA',
118
+ magenta: '#CBA6F7',
119
+ cyan: '#89DCEB',
120
+ gray: '#6C7086'
121
+ }, COLOR_HEX_TO_OPEN = Object.fromEntries(Object.values(COLOR_HEX).map((hex)=>[
122
+ hex,
123
+ ((hex)=>{
124
+ let r, g, b, value = (hex || '').trim().replace(/^#/, '');
125
+ 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);
126
+ else {
127
+ if (!/^[0-9a-fA-F]{6}$/.test(value)) return '';
128
+ r = Number.parseInt(value.slice(0, 2), 16), g = Number.parseInt(value.slice(2, 4), 16), b = Number.parseInt(value.slice(4, 6), 16);
129
+ }
130
+ return `\x1b[38;2;${r};${g};${b}m`;
131
+ })(hex)
132
+ ])), hexColor = (hex)=>{
133
+ if (disableColor) return (input)=>String(input);
134
+ let open = COLOR_HEX_TO_OPEN[hex];
135
+ return open ? (input)=>`${open}${input}\x1b[39m` : (input)=>String(input);
136
+ }, ansi = (open, close)=>(input)=>disableColor ? String(input) : `${open}${input}${close}`, colors = {
137
+ brand: hexColor(COLOR_HEX.brand),
138
+ red: hexColor(COLOR_HEX.red),
139
+ green: hexColor(COLOR_HEX.green),
140
+ yellow: hexColor(COLOR_HEX.yellow),
141
+ blue: hexColor(COLOR_HEX.blue),
142
+ magenta: hexColor(COLOR_HEX.magenta),
143
+ cyan: hexColor(COLOR_HEX.cyan),
144
+ gray: hexColor(COLOR_HEX.gray),
145
+ bold: ansi('\x1b[1m', '\x1b[22m'),
146
+ dim: ansi('\x1b[2m', '\x1b[22m')
147
+ }, CODE_TO_OPEN = Object.fromEntries(Object.entries({
148
+ 31: COLOR_HEX.red,
149
+ 32: COLOR_HEX.green,
150
+ 33: COLOR_HEX.yellow,
151
+ 34: COLOR_HEX.blue,
152
+ 35: COLOR_HEX.magenta,
153
+ 36: COLOR_HEX.cyan,
154
+ 90: COLOR_HEX.gray,
155
+ 91: COLOR_HEX.red,
156
+ 92: COLOR_HEX.green,
157
+ 93: COLOR_HEX.yellow,
158
+ 94: COLOR_HEX.blue,
159
+ 95: COLOR_HEX.magenta,
160
+ 96: COLOR_HEX.cyan
161
+ }).map(([code, hex])=>[
162
+ code,
163
+ COLOR_HEX_TO_OPEN[hex]
164
+ ]));
165
+ function convertBasicAnsiColors(input) {
166
+ let text = String(input ?? '');
167
+ return text ? disableColor ? text.replace(ANSI_SGR_RE, '') : text.replace(ANSI_OPEN_RE, (substring, params)=>{
168
+ let tokens = params.split(';').filter(Boolean), colorToken = tokens.find((t)=>t in CODE_TO_OPEN);
169
+ if (!colorToken) return substring;
170
+ let open = CODE_TO_OPEN[colorToken];
171
+ if (!open) return substring;
172
+ let styleTokens = tokens.filter((t)=>t !== colorToken), styleSeq = styleTokens.length ? `\x1b[${styleTokens.join(';')}m` : '';
173
+ return `${styleSeq}${open}`;
174
+ }) : '';
175
+ }
176
+ let restartCleaners = [], addRestartCleaner = (...cleaners)=>{
131
177
  restartCleaners.push(...cleaners);
132
178
  }, cleanUpBeforeRestart = async ()=>{
133
179
  await Promise.all(restartCleaners.map((cleaner)=>cleaner())), restartCleaners.length = 0;
@@ -282,7 +328,7 @@ for(var __webpack_i__ in (()=>{
282
328
  process.stdout.isTTY && (process.stdout.clearLine(0), process.stdout.cursorTo(0));
283
329
  }, logUpdate = (output)=>{
284
330
  clearLine(), process.stdout.write(output);
285
- }, isDebug = ()=>'unpack' === process.env.DEBUG, isCI = ()=>!!process.env.CI;
331
+ }, isDebug = ()=>'unpack' === process.env.DEBUG, utils_isCI = ()=>!!process.env.CI;
286
332
  function isNodeVersionAtLeast(major, minor) {
287
333
  let [currMajor, currMinor] = process.versions.node.split('.').map(Number);
288
334
  return currMajor > major || currMajor === major && currMinor >= minor;
@@ -735,7 +781,7 @@ for(var __webpack_i__ in (()=>{
735
781
  apply(compiler) {
736
782
  let meta = JSON.stringify({
737
783
  name: jsMinify_PLUGIN_NAME,
738
- version: "3.4.0",
784
+ version: "3.4.2",
739
785
  options: this.minifyOptions
740
786
  });
741
787
  compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
@@ -962,7 +1008,7 @@ for(var __webpack_i__ in (()=>{
962
1008
  }).time / 1000, sameCount = 0;
963
1009
  async function compileDone(compiler, stats) {
964
1010
  let root = compiler.options.context;
965
- if (!stats.hasErrors()) if (isProd()) isCI() || await printFileSize({
1011
+ if (!stats.hasErrors()) if (isProd()) utils_isCI() || await printFileSize({
966
1012
  root,
967
1013
  stats
968
1014
  }), logger_logger.ready(colors.green(`built in ${prettyTime(getCompileTime(stats))}`));
@@ -1048,7 +1094,7 @@ for(var __webpack_i__ in (()=>{
1048
1094
  count > 0 && console.log(`Found ${colors.red(colors.bold(`${count} ${1 === count ? 'error' : 'errors'}`))}`);
1049
1095
  },
1050
1096
  error (message) {
1051
- message.includes('RpcExitError') || message.includes('out of memory') || console.log(message.replace(/ERROR/g, 'Type Error'));
1097
+ message.includes('RpcExitError') || message.includes('out of memory') || console.log(convertBasicAnsiColors(message.replace(/ERROR/g, 'Type Error')));
1052
1098
  }
1053
1099
  }
1054
1100
  })), config;
@@ -1920,7 +1966,7 @@ for(var __webpack_i__ in (()=>{
1920
1966
  req.headers.accept?.includes('html') && (req.url = '/index.html'), next();
1921
1967
  }), middlewares.unshift(core_namespaceObject.experiments.lazyCompilationMiddleware(compiler)), middlewares);
1922
1968
  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.0`)} ${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())));
1969
+ await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.4.2`)} ${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
1970
  let open = unpackConfig.server?.open, url = isString(open) ? open : `http://localhost:${port}`;
1925
1971
  open && openBrowser(url), setupCliShortcuts({
1926
1972
  openPage: async ()=>{
@@ -1993,7 +2039,7 @@ for(var __webpack_i__ in (()=>{
1993
2039
  ...mergeConfig(defaultConfig, config),
1994
2040
  _context: {
1995
2041
  callerName,
1996
- version: "3.4.0"
2042
+ version: "3.4.2"
1997
2043
  }
1998
2044
  };
1999
2045
  };
@@ -2001,7 +2047,7 @@ for(var __webpack_i__ in (()=>{
2001
2047
  build: async ({ watch } = {})=>{
2002
2048
  setNodeEnv(watch ? 'development' : 'production');
2003
2049
  let config = resolveConfig();
2004
- console.log(colors.brand(`${callerName} v3.4.0`), colors.cyan(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
2050
+ console.log(colors.brand(`${callerName} v3.4.2`), colors.cyan(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
2005
2051
  },
2006
2052
  dev: async ()=>{
2007
2053
  global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
@@ -2028,7 +2074,7 @@ for(var __webpack_i__ in (()=>{
2028
2074
  ...options
2029
2075
  });
2030
2076
  }
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.hexColor = __webpack_exports__.hexColor, 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 === [
2077
+ })(), 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
2078
  "CSS_MODULES_LOCAL_IDENT_NAME",
2033
2079
  "CSS_MODULES_REGEX",
2034
2080
  "CSS_NAMED_EXPORT",
@@ -2045,6 +2091,7 @@ for(var __webpack_i__ in (()=>{
2045
2091
  "cleanUpBeforeRestart",
2046
2092
  "clearLine",
2047
2093
  "colors",
2094
+ "convertBasicAnsiColors",
2048
2095
  "createChokidar",
2049
2096
  "createUnpack",
2050
2097
  "currentDevUnpackConfig",
@@ -2062,7 +2109,6 @@ for(var __webpack_i__ in (()=>{
2062
2109
  "getUserDepPath",
2063
2110
  "getUserDepVersion",
2064
2111
  "getValueByPath",
2065
- "hexColor",
2066
2112
  "isBoolean",
2067
2113
  "isCI",
2068
2114
  "isCSSModules",
package/dist/index.js CHANGED
@@ -34,27 +34,73 @@ function __webpack_require__(moduleId) {
34
34
  };
35
35
  return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
36
36
  }
37
- let hexColor = (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 (input)=>String(input);
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
- }
44
- let prefix = `\x1b[38;2;${r};${g};${b}m`;
45
- return (input)=>`${prefix}${input}\x1b[39m`;
46
- }, colors = {
47
- brand: hexColor('#b39aff'),
48
- red: hexColor('#F38BA8'),
49
- green: hexColor('#A6E3A1'),
50
- yellow: hexColor('#F9E2AF'),
51
- blue: hexColor('#89B4FA'),
52
- magenta: hexColor('#CBA6F7'),
53
- cyan: hexColor('#89DCEB'),
54
- gray: hexColor('#6C7086'),
55
- bold: (input)=>`\x1b[1m${input}\x1b[22m`,
56
- dim: (input)=>`\x1b[2m${input}\x1b[22m`
57
- }, restartCleaners = [], addRestartCleaner = (...cleaners)=>{
37
+ let isCI = !!process.env.CI, isTTY = !!process.stdout?.isTTY, noColor = !!process.env.NO_COLOR, forceColor = !!process.env.FORCE_COLOR, disableColor = !1;
38
+ disableColor = !!noColor || !forceColor && (isCI || !isTTY);
39
+ let ANSI_SGR_RE = /\x1b\[[0-9;]*m/g, ANSI_OPEN_RE = /\x1b\[([0-9;]+)m/g, COLOR_HEX = {
40
+ brand: '#b39aff',
41
+ red: '#F38BA8',
42
+ green: '#A6E3A1',
43
+ yellow: '#F9E2AF',
44
+ blue: '#89B4FA',
45
+ magenta: '#CBA6F7',
46
+ cyan: '#89DCEB',
47
+ gray: '#6C7086'
48
+ }, COLOR_HEX_TO_OPEN = Object.fromEntries(Object.values(COLOR_HEX).map((hex)=>[
49
+ hex,
50
+ ((hex)=>{
51
+ let r, g, b, value = (hex || '').trim().replace(/^#/, '');
52
+ 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);
53
+ else {
54
+ if (!/^[0-9a-fA-F]{6}$/.test(value)) return '';
55
+ r = Number.parseInt(value.slice(0, 2), 16), g = Number.parseInt(value.slice(2, 4), 16), b = Number.parseInt(value.slice(4, 6), 16);
56
+ }
57
+ return `\x1b[38;2;${r};${g};${b}m`;
58
+ })(hex)
59
+ ])), hexColor = (hex)=>{
60
+ if (disableColor) return (input)=>String(input);
61
+ let open = COLOR_HEX_TO_OPEN[hex];
62
+ return open ? (input)=>`${open}${input}\x1b[39m` : (input)=>String(input);
63
+ }, ansi = (open, close)=>(input)=>disableColor ? String(input) : `${open}${input}${close}`, colors = {
64
+ brand: hexColor(COLOR_HEX.brand),
65
+ red: hexColor(COLOR_HEX.red),
66
+ green: hexColor(COLOR_HEX.green),
67
+ yellow: hexColor(COLOR_HEX.yellow),
68
+ blue: hexColor(COLOR_HEX.blue),
69
+ magenta: hexColor(COLOR_HEX.magenta),
70
+ cyan: hexColor(COLOR_HEX.cyan),
71
+ gray: hexColor(COLOR_HEX.gray),
72
+ bold: ansi('\x1b[1m', '\x1b[22m'),
73
+ dim: ansi('\x1b[2m', '\x1b[22m')
74
+ }, CODE_TO_OPEN = Object.fromEntries(Object.entries({
75
+ 31: COLOR_HEX.red,
76
+ 32: COLOR_HEX.green,
77
+ 33: COLOR_HEX.yellow,
78
+ 34: COLOR_HEX.blue,
79
+ 35: COLOR_HEX.magenta,
80
+ 36: COLOR_HEX.cyan,
81
+ 90: COLOR_HEX.gray,
82
+ 91: COLOR_HEX.red,
83
+ 92: COLOR_HEX.green,
84
+ 93: COLOR_HEX.yellow,
85
+ 94: COLOR_HEX.blue,
86
+ 95: COLOR_HEX.magenta,
87
+ 96: COLOR_HEX.cyan
88
+ }).map(([code, hex])=>[
89
+ code,
90
+ COLOR_HEX_TO_OPEN[hex]
91
+ ]));
92
+ function convertBasicAnsiColors(input) {
93
+ let text = String(input ?? '');
94
+ return text ? disableColor ? text.replace(ANSI_SGR_RE, '') : text.replace(ANSI_OPEN_RE, (substring, params)=>{
95
+ let tokens = params.split(';').filter(Boolean), colorToken = tokens.find((t)=>t in CODE_TO_OPEN);
96
+ if (!colorToken) return substring;
97
+ let open = CODE_TO_OPEN[colorToken];
98
+ if (!open) return substring;
99
+ let styleTokens = tokens.filter((t)=>t !== colorToken), styleSeq = styleTokens.length ? `\x1b[${styleTokens.join(';')}m` : '';
100
+ return `${styleSeq}${open}`;
101
+ }) : '';
102
+ }
103
+ let restartCleaners = [], addRestartCleaner = (...cleaners)=>{
58
104
  restartCleaners.push(...cleaners);
59
105
  }, cleanUpBeforeRestart = async ()=>{
60
106
  await Promise.all(restartCleaners.map((cleaner)=>cleaner())), restartCleaners.length = 0;
@@ -198,7 +244,7 @@ let debounce = (fn, delay)=>{
198
244
  process.stdout.isTTY && (process.stdout.clearLine(0), process.stdout.cursorTo(0));
199
245
  }, logUpdate = (output)=>{
200
246
  clearLine(), process.stdout.write(output);
201
- }, isDebug = ()=>'unpack' === process.env.DEBUG, isCI = ()=>!!process.env.CI;
247
+ }, isDebug = ()=>'unpack' === process.env.DEBUG, utils_isCI = ()=>!!process.env.CI;
202
248
  function isNodeVersionAtLeast(major, minor) {
203
249
  let [currMajor, currMinor] = process.versions.node.split('.').map(Number);
204
250
  return currMajor > major || currMajor === major && currMinor >= minor;
@@ -649,7 +695,7 @@ class JsMinifyPlugin {
649
695
  apply(compiler) {
650
696
  let meta = JSON.stringify({
651
697
  name: jsMinify_PLUGIN_NAME,
652
- version: "3.4.0",
698
+ version: "3.4.2",
653
699
  options: this.minifyOptions
654
700
  });
655
701
  compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
@@ -873,7 +919,7 @@ let getCompileTime = (stats)=>stats.toJson({
873
919
  }).time / 1000, sameCount = 0;
874
920
  async function compileDone(compiler, stats) {
875
921
  let root = compiler.options.context;
876
- if (!stats.hasErrors()) if (isProd()) isCI() || await printFileSize({
922
+ if (!stats.hasErrors()) if (isProd()) utils_isCI() || await printFileSize({
877
923
  root,
878
924
  stats
879
925
  }), logger_logger.ready(colors.green(`built in ${prettyTime(getCompileTime(stats))}`));
@@ -958,7 +1004,7 @@ async function applyTypeCheckConfig({ config, unpackConfig }) {
958
1004
  count > 0 && console.log(`Found ${colors.red(colors.bold(`${count} ${1 === count ? 'error' : 'errors'}`))}`);
959
1005
  },
960
1006
  error (message) {
961
- message.includes('RpcExitError') || message.includes('out of memory') || console.log(message.replace(/ERROR/g, 'Type Error'));
1007
+ message.includes('RpcExitError') || message.includes('out of memory') || console.log(convertBasicAnsiColors(message.replace(/ERROR/g, 'Type Error')));
962
1008
  }
963
1009
  }
964
1010
  })), config;
@@ -1828,7 +1874,7 @@ async function unpackDev(originalUnpackConfig) {
1828
1874
  req.headers.accept?.includes('html') && (req.url = '/index.html'), next();
1829
1875
  }), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
1830
1876
  let server = new RspackDevServer(devServerOptions, compiler);
1831
- await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.4.0`)} ${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())));
1877
+ await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.4.2`)} ${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
1878
  let open = unpackConfig.server?.open, url = isString(open) ? open : `http://localhost:${port}`;
1833
1879
  open && openBrowser(url), setupCliShortcuts({
1834
1880
  openPage: async ()=>{
@@ -1901,7 +1947,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
1901
1947
  ...mergeConfig(defaultConfig, config),
1902
1948
  _context: {
1903
1949
  callerName,
1904
- version: "3.4.0"
1950
+ version: "3.4.2"
1905
1951
  }
1906
1952
  };
1907
1953
  };
@@ -1909,7 +1955,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
1909
1955
  build: async ({ watch } = {})=>{
1910
1956
  setNodeEnv(watch ? 'development' : 'production');
1911
1957
  let config = resolveConfig();
1912
- console.log(colors.brand(`${callerName} v3.4.0`), colors.cyan(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
1958
+ console.log(colors.brand(`${callerName} v3.4.2`), colors.cyan(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
1913
1959
  },
1914
1960
  dev: async ()=>{
1915
1961
  global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
@@ -1934,4 +1980,4 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
1934
1980
  var __webpack_exports__CSS_NAMED_EXPORT = !1;
1935
1981
  import { fileURLToPath as __webpack_fileURLToPath__, pathToFileURL } from "node:url";
1936
1982
  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, hexColor, 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 };
1983
+ 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, utils_isCI as 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,51 @@ 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[\\/]/, hexColor = (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 (input)=>String(input);
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
- }
31
- let prefix = `\x1b[38;2;${r};${g};${b}m`;
32
- return (input)=>`${prefix}${input}\x1b[39m`;
33
- };
34
- hexColor('#b39aff'), hexColor('#F38BA8'), hexColor('#A6E3A1'), hexColor('#F9E2AF'), hexColor('#89B4FA'), hexColor('#CBA6F7'), hexColor('#89DCEB'), hexColor('#6C7086');
24
+ let CSS_MODULES_REGEX = /\.module\.\w+$/i, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, isCI = !!process.env.CI, isTTY = !!process.stdout?.isTTY, noColor = !!process.env.NO_COLOR, forceColor = !!process.env.FORCE_COLOR, disableColor = !1;
25
+ disableColor = !!noColor || !forceColor && (isCI || !isTTY);
26
+ let COLOR_HEX = {
27
+ brand: '#b39aff',
28
+ red: '#F38BA8',
29
+ green: '#A6E3A1',
30
+ yellow: '#F9E2AF',
31
+ blue: '#89B4FA',
32
+ magenta: '#CBA6F7',
33
+ cyan: '#89DCEB',
34
+ gray: '#6C7086'
35
+ }, COLOR_HEX_TO_OPEN = Object.fromEntries(Object.values(COLOR_HEX).map((hex)=>[
36
+ hex,
37
+ ((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);
43
+ }
44
+ return `\x1b[38;2;${r};${g};${b}m`;
45
+ })(hex)
46
+ ])), hexColor = (hex)=>{
47
+ if (disableColor) return (input)=>String(input);
48
+ let open = COLOR_HEX_TO_OPEN[hex];
49
+ return open ? (input)=>`${open}${input}\x1b[39m` : (input)=>String(input);
50
+ }, ansi = (open, close)=>(input)=>disableColor ? String(input) : `${open}${input}${close}`;
51
+ hexColor(COLOR_HEX.brand), 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'), Object.fromEntries(Object.entries({
52
+ 31: COLOR_HEX.red,
53
+ 32: COLOR_HEX.green,
54
+ 33: COLOR_HEX.yellow,
55
+ 34: COLOR_HEX.blue,
56
+ 35: COLOR_HEX.magenta,
57
+ 36: COLOR_HEX.cyan,
58
+ 90: COLOR_HEX.gray,
59
+ 91: COLOR_HEX.red,
60
+ 92: COLOR_HEX.green,
61
+ 93: COLOR_HEX.yellow,
62
+ 94: COLOR_HEX.blue,
63
+ 95: COLOR_HEX.magenta,
64
+ 96: COLOR_HEX.cyan
65
+ }).map(([code, hex])=>[
66
+ code,
67
+ COLOR_HEX_TO_OPEN[hex]
68
+ ]));
35
69
  let { merge } = __webpack_require__("compiled/webpack-merge");
36
70
  __webpack_require__("compiled/launch-editor");
37
71
  let enforceLFLineSeparators = (text)=>text ? text.replace(/\r\n/g, '\n') : text;
@@ -12,7 +12,26 @@ 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
+ * - 91 bright-red
29
+ * - 92 bright-green
30
+ * - 93 bright-yellow
31
+ * - 94 bright-blue
32
+ * - 95 bright-magenta
33
+ * - 96 bright-cyan
34
+ */
35
+ export declare function convertBasicAnsiColors(input: string): string;
17
36
  export {};
18
37
  //# 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;AAED,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,KAAG,SAmBtC,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,MAWpB,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;AA6ED,eAAO,MAAM,MAAM,EAAE,MAWpB,CAAA;AAuBD;;;;;;;;;;;;;;;;;;GAkBG;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.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "An Rspack-based build tool",
5
5
  "type": "module",
6
6
  "exports": {