@unpackjs/core 3.8.2 → 3.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -729,26 +729,23 @@ let getOutputFilename = ({ type, hash, async })=>{
729
729
  };
730
730
  var css_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
731
731
  async function applyHtmlConfig({ config, unpackConfig }) {
732
- if (!unpackConfig.mpa) {
733
- let htmlConfig = unpackConfig.html || {}, { template, templateContent } = getHtmlTemplateOrContent(htmlConfig.template, unpackConfig.root), templateParameters = {
734
- mountId: htmlConfig.mountId,
735
- title: isFunction(htmlConfig.title) ? htmlConfig.title({
736
- entryName: 'index'
737
- }) : htmlConfig.title || '',
738
- headTag: htmlConfig.headTag || '',
739
- ...htmlConfig.templateParameters
740
- };
741
- config.plugins.push(new rspack.HtmlRspackPlugin({
742
- template,
743
- templateContent,
744
- templateParameters,
745
- minify: !1,
746
- chunks: [
747
- 'main'
748
- ]
749
- }));
750
- }
751
- return config;
732
+ let htmlConfig = unpackConfig.html || {}, { template, templateContent } = getHtmlTemplateOrContent(htmlConfig.template, unpackConfig.root), templateParameters = {
733
+ mountId: htmlConfig.mountId,
734
+ title: isFunction(htmlConfig.title) ? htmlConfig.title({
735
+ entryName: 'index'
736
+ }) : htmlConfig.title || '',
737
+ headTag: htmlConfig.headTag || '',
738
+ ...htmlConfig.templateParameters
739
+ };
740
+ return config.plugins.push(new rspack.HtmlRspackPlugin({
741
+ template,
742
+ templateContent,
743
+ templateParameters,
744
+ minify: !1,
745
+ chunks: [
746
+ 'main'
747
+ ]
748
+ })), config;
752
749
  }
753
750
  let { RawSource: RawSource, SourceMapSource: SourceMapSource } = rspack.sources, isJsFile = /\.[cm]?js(\?.*)?$/i, jsMinify_PLUGIN_NAME = 'JsMinifyPlugin';
754
751
  class JsMinifyPlugin {
@@ -761,7 +758,7 @@ class JsMinifyPlugin {
761
758
  apply(compiler) {
762
759
  let meta = JSON.stringify({
763
760
  name: jsMinify_PLUGIN_NAME,
764
- version: "3.8.2",
761
+ version: "3.8.3",
765
762
  options: this.minifyOptions
766
763
  });
767
764
  compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
@@ -1163,9 +1160,6 @@ async function getBundlerConfig(originalUnpackConfig) {
1163
1160
  }
1164
1161
  }
1165
1162
  ]
1166
- }), config = await applyHtmlConfig({
1167
- config,
1168
- unpackConfig
1169
1163
  }), config = (({ config, unpackConfig })=>{
1170
1164
  let { chunkSplit } = unpackConfig.performance || {};
1171
1165
  if (chunkSplit?.strategy) {
@@ -1430,7 +1424,10 @@ async function getBundlerConfig(originalUnpackConfig) {
1430
1424
  unpackConfig
1431
1425
  }),
1432
1426
  unpackConfig
1433
- }), unpackConfig.performance?.cache && (config = await applyCacheConfig({
1427
+ }), unpackConfig.mpa || (config = await applyHtmlConfig({
1428
+ config,
1429
+ unpackConfig
1430
+ })), unpackConfig.performance?.cache && (config = await applyCacheConfig({
1434
1431
  config,
1435
1432
  unpackConfig,
1436
1433
  envFilePaths
@@ -1447,34 +1444,26 @@ async function getBundlerConfig(originalUnpackConfig) {
1447
1444
  circularCount = 0;
1448
1445
  },
1449
1446
  onDetected (_, modules) {
1450
- circularCount++, console.log(''), logger_logger.warn('circular dependency detected:');
1451
- let uniquePaths = modules.map((module)=>{
1447
+ var paths;
1448
+ let arrow, lastIndex;
1449
+ circularCount++, logger_logger.warn('circular dependency detected:'), paths = modules.map((module)=>{
1452
1450
  let filePath = module.replace(/^.*!/, ''), relativePath = node_path.relative(unpackConfig.root, filePath);
1453
1451
  return relativePath.startsWith('..') ? filePath : relativePath;
1454
- }).slice(0, -1);
1455
- if (2 + uniquePaths.join(' → ').length > (process.stdout.columns || 80)) {
1456
- let arrow, lastIndex;
1457
- console.log(''), arrow = '↳ ', lastIndex = uniquePaths.length - 1, uniquePaths.forEach((p, i)=>{
1458
- switch(i){
1459
- case 0:
1460
- console.log(` ${p}`);
1461
- break;
1462
- case lastIndex:
1463
- console.log(` ${arrow}${p} ${colors.dim('(cycle introduced)')}`);
1464
- break;
1465
- default:
1466
- console.log(` ${arrow}${p}`);
1467
- }
1468
- }), console.log(` ${arrow}${uniquePaths[0]}`), console.log('');
1469
- } else {
1470
- let line1, downArrowPos, lineLength;
1471
- line1 = ' ', downArrowPos = 0, uniquePaths.forEach((p, i)=>{
1472
- line1 += p, i < uniquePaths.length - 1 ? line1 += ' → ' : downArrowPos = line1.length - 1;
1473
- }), lineLength = downArrowPos - 2, console.log(''), console.log(line1), console.log(' ' + ' '.repeat(0) + '↑' + ' '.repeat(downArrowPos - 2 - 1) + '↓'), console.log(' ' + ' '.repeat(0) + '└' + '─'.repeat(lineLength - 1) + '┘'), console.log('');
1474
- }
1452
+ }).slice(0, -1), console.log(''), arrow = colors.dim('↳ '), lastIndex = paths.length - 1, paths.forEach((p, i)=>{
1453
+ switch(i){
1454
+ case 0:
1455
+ console.log(` ${p}`);
1456
+ break;
1457
+ case lastIndex:
1458
+ console.log(` ${arrow}${p} ${colors.yellow(colors.dim('(cycle introduced)'))}`);
1459
+ break;
1460
+ default:
1461
+ console.log(` ${arrow}${p}`);
1462
+ }
1463
+ }), console.log(` ${arrow}${paths[0]}`), console.log('');
1475
1464
  },
1476
1465
  onEnd () {
1477
- circularCount > 0 && console.log(`Found ${circularCount} circular ${1 === circularCount ? 'dependency' : 'dependencies'}`);
1466
+ circularCount > 0 && console.log('Found', colors.yellow(colors.bold(`${circularCount} circular ${1 === circularCount ? 'dependency' : 'dependencies'}`)));
1478
1467
  }
1479
1468
  });
1480
1469
  return config.plugins?.push(circularDependencyPlugin), config;
@@ -1609,7 +1598,7 @@ async function unpackDev(unpackConfig) {
1609
1598
  ...middlewares
1610
1599
  ]);
1611
1600
  let server = new RspackDevServer(devServerOptions, compiler);
1612
- await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.8.2${unpackConfig.performance?.cache ? ' ϟ' : ''}`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - getUnpackStartTime()))} ${colors.dim('ms')}\n`), printServerUrls({
1601
+ await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.8.3${unpackConfig.performance?.cache ? ' ϟ' : ''}`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - getUnpackStartTime()))} ${colors.dim('ms')}\n`), printServerUrls({
1613
1602
  port,
1614
1603
  host: unpackConfig.server?.host,
1615
1604
  base: unpackConfig.base
@@ -1623,7 +1612,7 @@ async function unpackDev(unpackConfig) {
1623
1612
  function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'unpack' }) {
1624
1613
  let _context = {
1625
1614
  callerName,
1626
- version: "3.8.2",
1615
+ version: "3.8.3",
1627
1616
  cachePath: 'node_modules/.unpack'
1628
1617
  }, resolveConfig = (mode)=>{
1629
1618
  let rootPath, outputPath, basePath, cachedTraceMap, fs, isValidMethodName, parseFrame, formatOriginalLocation, formatFullStack, resolveErrorLocationAndStack, shouldTransformDeepImport, preJsAssets, jsAssets, cssAssets, bundledDepsCachePath, deepImportPkgPattern, deepImportRegex, root;
@@ -1731,7 +1720,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
1731
1720
  /(^|[\\/])src[\\/]/.test(locationText) && srcLines.push(line);
1732
1721
  }
1733
1722
  }
1734
- return srcLines.length > 0 ? srcLines.join('') : allLines.join('');
1723
+ return srcLines.length > 0 ? srcLines[0] : allLines.join('');
1735
1724
  }, resolveErrorLocationAndStack = async (item)=>{
1736
1725
  let locationFromMsg = item.message ? ((message)=>{
1737
1726
  let match = message.match(/((?:[A-Za-z]:)?\/[^\s:]+):(\d+):(\d+)/);
@@ -1864,12 +1853,11 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
1864
1853
  }
1865
1854
  switch(item.type){
1866
1855
  case 'string':
1867
- return ((message)=>{
1868
- let trimmed = message.trim();
1869
- if (!trimmed) return !0;
1870
- let normalizedFirstLine = (trimmed.split('\n', 1)[0]?.trim() || '').replace(/`/g, '');
1871
- return /^at\s+/.test(normalizedFirstLine);
1872
- })(item.message) ? '' : item.message;
1856
+ let trimmed;
1857
+ return (trimmed = item.message.trim()) ? trimmed.split(/\r?\n/g).filter((line)=>{
1858
+ let normalized = line.trim().replace(/`/g, '');
1859
+ return !!normalized && !/^at\s+/.test(normalized);
1860
+ }).join('\n').trim() : '';
1873
1861
  case 'null':
1874
1862
  return null;
1875
1863
  case 'undefined':
@@ -1905,7 +1893,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
1905
1893
  format(cleanedTemplate, ...rest)
1906
1894
  ];
1907
1895
  })(formattedArgs), prefix = colors.dim(`[browser ${time}]`);
1908
- switch(level){
1896
+ switch(console.log(''), level){
1909
1897
  case 'error':
1910
1898
  logger_logger.error(`${prefix} ${outputArgs.join(' ')}`);
1911
1899
  break;
@@ -1932,7 +1920,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
1932
1920
  apply: (config, { command })=>'dev' === command && !!config.dev?.prebundle,
1933
1921
  config: async (config, context)=>{
1934
1922
  var externals;
1935
- let existExternals, cacheDir, root = config.root;
1923
+ let existExternals, root = config.root;
1936
1924
  bundledDepsCachePath = node_path.resolve(root, context.cachePath, 'umd');
1937
1925
  let count = {
1938
1926
  total: 0,
@@ -2123,9 +2111,16 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2123
2111
  });
2124
2112
  });
2125
2113
  }))(depInfo)));
2126
- cacheDir = node_path.dirname(failedDepsJsonPath), node_fs.existsSync(cacheDir) || node_fs.mkdirSync(cacheDir, {
2127
- recursive: !0
2128
- }), node_fs.writeFileSync(failedDepsJsonPath, JSON.stringify(failedCache, null, 2), 'utf-8');
2114
+ ((cache)=>{
2115
+ if (0 === Object.keys(cache).length) {
2116
+ node_fs.existsSync(failedDepsJsonPath) && node_fs.unlinkSync(failedDepsJsonPath);
2117
+ return;
2118
+ }
2119
+ let cacheDir = node_path.dirname(failedDepsJsonPath);
2120
+ node_fs.existsSync(cacheDir) || node_fs.mkdirSync(cacheDir, {
2121
+ recursive: !0
2122
+ }), node_fs.writeFileSync(failedDepsJsonPath, JSON.stringify(cache, null, 2), 'utf-8');
2123
+ })(failedCache);
2129
2124
  let externals1 = {};
2130
2125
  bundledDeps.filter(Boolean).forEach((dep)=>{
2131
2126
  dep && (externals1[dep.name] = getExternalValue(dep.name), dep.assets.forEach((absPath)=>{
@@ -2273,7 +2268,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2273
2268
  let mode = watch ? 'development' : 'production';
2274
2269
  setNodeEnv(mode);
2275
2270
  let config = resolveConfig(mode);
2276
- console.log(colors.brand(`${callerName} v3.8.2${config.performance?.cache ? ' ϟ' : ''}`), colors.cyan(`building for ${mode}...`)), await unpackBuild(config);
2271
+ console.log(colors.brand(`${callerName} v3.8.3${config.performance?.cache ? ' ϟ' : ''}`), colors.cyan(`building for ${mode}...`)), await unpackBuild(config);
2277
2272
  },
2278
2273
  dev: async ()=>{
2279
2274
  setUnpackStartTime(performance.now());
@@ -14,52 +14,7 @@ __webpack_require__.add({
14
14
  module.exports = __rspack_external__compiled_webpack_merge_index_js_efd91626;
15
15
  }
16
16
  });
17
- 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;
18
- disableColor = !!noColor || !forceColor && (isCI || !isTTY);
19
- let COLOR_HEX = {
20
- brand: '#B39AFF',
21
- red: '#F38BA8',
22
- green: '#A6E3A1',
23
- yellow: '#F9E2AF',
24
- blue: '#89B4FA',
25
- magenta: '#EE90DB',
26
- cyan: '#89DCEB',
27
- gray: '#6C7086'
28
- }, COLOR_HEX_TO_OPEN = Object.fromEntries(Object.values(COLOR_HEX).map((hex)=>[
29
- hex,
30
- ((hex)=>{
31
- let r, g, b, value = (hex || '').trim().replace(/^#/, '');
32
- 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);
33
- else {
34
- if (!/^[0-9a-fA-F]{6}$/.test(value)) return '';
35
- r = Number.parseInt(value.slice(0, 2), 16), g = Number.parseInt(value.slice(2, 4), 16), b = Number.parseInt(value.slice(4, 6), 16);
36
- }
37
- return `\x1b[38;2;${r};${g};${b}m`;
38
- })(hex)
39
- ])), hexColor = (hex)=>{
40
- if (disableColor) return (input)=>String(input);
41
- let open = COLOR_HEX_TO_OPEN[hex];
42
- return open ? (input)=>`${open}${input}\x1b[39m` : (input)=>String(input);
43
- }, ansi = (open, close)=>(input)=>disableColor ? String(input) : `${open}${input}${close}`;
44
- 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({
45
- 31: COLOR_HEX.red,
46
- 32: COLOR_HEX.green,
47
- 33: COLOR_HEX.yellow,
48
- 34: COLOR_HEX.blue,
49
- 35: COLOR_HEX.magenta,
50
- 36: COLOR_HEX.cyan,
51
- 90: COLOR_HEX.gray,
52
- 91: COLOR_HEX.red,
53
- 92: COLOR_HEX.green,
54
- 93: COLOR_HEX.yellow,
55
- 94: COLOR_HEX.blue,
56
- 95: COLOR_HEX.magenta,
57
- 96: COLOR_HEX.cyan
58
- }).map(([code, hex])=>[
59
- code,
60
- COLOR_HEX_TO_OPEN[hex]
61
- ]));
62
- let { merge: mergeConfig } = __webpack_require__("compiled/webpack-merge"), { default: launchEditor } = __webpack_require__("compiled/launch-editor"), enforceLFLineSeparators = (text)=>text ? text.replace(/\r\n/g, '\n') : text;
17
+ let CSS_MODULES_REGEX = /\.module\.\w+$/i, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, { merge: mergeConfig } = __webpack_require__("compiled/webpack-merge"), { default: launchEditor } = __webpack_require__("compiled/launch-editor"), enforceLFLineSeparators = (text)=>text ? text.replace(/\r\n/g, '\n') : text;
63
18
  export default function(content, ...rest) {
64
19
  var keys;
65
20
  let interfaceFields, bannerMessage, callback, dirName, baseName, filename, { failed, success } = (callback = this.async(), {
@@ -1 +1 @@
1
- {"version":3,"file":"detectCircular.d.ts","sourceRoot":"","sources":["../../src/bundler-config/detectCircular.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAqEnE,wBAAgB,yBAAyB,CAAC,EACxC,MAAM,EACN,YAAY,GACb,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,GAAG,oBAAoB,CAmDvB"}
1
+ {"version":3,"file":"detectCircular.d.ts","sourceRoot":"","sources":["../../src/bundler-config/detectCircular.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAyBnE,wBAAgB,yBAAyB,CAAC,EACxC,MAAM,EACN,YAAY,GACb,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,GAAG,oBAAoB,CAwCvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/bundler-config/html.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAGnE,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,YAAY,GACb,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA6BhC"}
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/bundler-config/html.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAGnE,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,YAAY,GACb,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA2BhC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-config/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAiB,MAAM,WAAW,CAAA;AAwBlF,wBAAsB,gBAAgB,CACpC,oBAAoB,EAAE,YAAY,GACjC,OAAO,CAAC,oBAAoB,CAAC,CAgN/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-config/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAiB,MAAM,WAAW,CAAA;AAwBlF,wBAAsB,gBAAgB,CACpC,oBAAoB,EAAE,YAAY,GACjC,OAAO,CAAC,oBAAoB,CAAC,CAkN/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"browserLogs.d.ts","sourceRoot":"","sources":["../../src/plugins/browserLogs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AA6B7C,eAAO,MAAM,iBAAiB,QAAO,YA+YpC,CAAA"}
1
+ {"version":3,"file":"browserLogs.d.ts","sourceRoot":"","sources":["../../src/plugins/browserLogs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AA6B7C,eAAO,MAAM,iBAAiB,QAAO,YAmZpC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"prebundle.d.ts","sourceRoot":"","sources":["../../src/plugins/prebundle.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,WAAW,CAAA;AAkGnE,eAAO,MAAM,eAAe,QAAO,YAsYlC,CAAA"}
1
+ {"version":3,"file":"prebundle.d.ts","sourceRoot":"","sources":["../../src/plugins/prebundle.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,WAAW,CAAA;AAkGnE,eAAO,MAAM,eAAe,QAAO,YA4YlC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unpackjs/core",
3
- "version": "3.8.2",
3
+ "version": "3.8.3",
4
4
  "description": "An Rspack-based build tool",
5
5
  "type": "module",
6
6
  "exports": {
@@ -11,6 +11,7 @@
11
11
  "./package.json": "./package.json"
12
12
  },
13
13
  "types": "./dist-types/index.d.ts",
14
+ "sideEffects": false,
14
15
  "keywords": [],
15
16
  "authors": [],
16
17
  "license": "MIT",