@unpackjs/core 2.4.5 → 3.1.0

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.
Files changed (47) hide show
  1. package/compiled/css-loader/index.js +22 -22
  2. package/compiled/less-loader/index.js +8 -8
  3. package/compiled/postcss-loader/index.js +8 -8
  4. package/compiled/sass-loader/index.js +8 -8
  5. package/dist/index.cjs +222 -256
  6. package/dist/index.js +215 -243
  7. package/dist/typedCssModulesLoader.mjs +4 -62
  8. package/dist-types/bundler-config/cache.d.ts.map +1 -1
  9. package/dist-types/bundler-config/css.d.ts.map +1 -1
  10. package/dist-types/bundler-config/experimentCss.d.ts.map +1 -1
  11. package/dist-types/bundler-config/index.d.ts.map +1 -1
  12. package/dist-types/bundler-config/plugins/jsMinify.d.ts +2 -2
  13. package/dist-types/bundler-config/plugins/jsMinify.d.ts.map +1 -1
  14. package/dist-types/bundler-config/plugins/progress/{rspack.d.ts → index.d.ts} +1 -1
  15. package/dist-types/bundler-config/plugins/progress/index.d.ts.map +1 -0
  16. package/dist-types/bundler-config/plugins/typedCssModules.d.ts +1 -1
  17. package/dist-types/bundler-config/plugins/typedCssModules.d.ts.map +1 -1
  18. package/dist-types/constants.d.ts +0 -1
  19. package/dist-types/constants.d.ts.map +1 -1
  20. package/dist-types/createUnpack.d.ts.map +1 -1
  21. package/dist-types/index.d.ts +0 -2
  22. package/dist-types/index.d.ts.map +1 -1
  23. package/dist-types/logger.d.ts.map +1 -1
  24. package/dist-types/openBrowser.d.ts.map +1 -1
  25. package/dist-types/prebundleDeps.d.ts.map +1 -1
  26. package/dist-types/progressBar.d.ts +0 -1
  27. package/dist-types/progressBar.d.ts.map +1 -1
  28. package/dist-types/reporter.d.ts +1 -2
  29. package/dist-types/reporter.d.ts.map +1 -1
  30. package/dist-types/run/build.d.ts.map +1 -1
  31. package/dist-types/run/dev.d.ts.map +1 -1
  32. package/dist-types/types/config.d.ts +8 -9
  33. package/dist-types/types/config.d.ts.map +1 -1
  34. package/dist-types/types/index.d.ts +0 -1
  35. package/dist-types/types/index.d.ts.map +1 -1
  36. package/dist-types/utils.d.ts.map +1 -1
  37. package/package.json +4 -11
  38. package/dist/lightningcssLoader.mjs +0 -18
  39. package/dist-types/bundler-config/loaders/lightningcssLoader.d.ts +0 -5
  40. package/dist-types/bundler-config/loaders/lightningcssLoader.d.ts.map +0 -1
  41. package/dist-types/bundler-config/plugins/lightningcssMinify.d.ts +0 -10
  42. package/dist-types/bundler-config/plugins/lightningcssMinify.d.ts.map +0 -1
  43. package/dist-types/bundler-config/plugins/progress/rspack.d.ts.map +0 -1
  44. package/dist-types/bundler-config/plugins/progress/webpack.d.ts +0 -9
  45. package/dist-types/bundler-config/plugins/progress/webpack.d.ts.map +0 -1
  46. package/dist-types/types/lightningcss.d.ts +0 -11
  47. package/dist-types/types/lightningcss.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -5,8 +5,6 @@ import { dirname as __webpack_dirname__ } from "node:path";
5
5
  import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_bundle_analyzer_index_js_1177eada__ from "../compiled/webpack-bundle-analyzer/index.js";
6
6
  import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_merge_index_js_efd91626__ from "../compiled/webpack-merge/index.js";
7
7
  import { experiments, rspack } from "@rspack/core";
8
- import html_webpack_plugin from "html-webpack-plugin";
9
- import webpack from "webpack";
10
8
  import picocolors from "picocolors";
11
9
  import node_fs from "node:fs";
12
10
  import node_path, { join, sep } from "node:path";
@@ -14,23 +12,17 @@ import { pathToFileURL } from "node:url";
14
12
  import { createJiti } from "jiti";
15
13
  import node_readline from "node:readline";
16
14
  import node_net from "node:net";
17
- import node_os from "node:os";
15
+ import node_os, { platform } from "node:os";
18
16
  import portfinder from "portfinder";
19
- import { browserslistToTargets, transform } from "lightningcss";
20
- import copy_webpack_plugin from "copy-webpack-plugin";
21
- import json5 from "json5";
22
17
  import { expand } from "dotenv-expand";
23
18
  import { TsCheckerRspackPlugin } from "ts-checker-rspack-plugin";
24
19
  import node_assert from "node:assert";
25
- import mini_css_extract_plugin from "mini-css-extract-plugin";
26
20
  import { glob, globSync } from "tinyglobby";
27
21
  import typed_css_modules from "typed-css-modules";
28
22
  import { minify } from "oxc-minify";
29
- import { Buffer as external_node_buffer_Buffer } from "node:buffer";
30
23
  import { exec, spawn } from "node:child_process";
31
24
  import { promisify } from "node:util";
32
25
  import node_zlib from "node:zlib";
33
- import open_0 from "open";
34
26
  import cors from "cors";
35
27
  import express from "express";
36
28
  import webpack_dev_server from "webpack-dev-server";
@@ -79,7 +71,7 @@ let CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]', CSS_MODULE
79
71
  'edge >= 107',
80
72
  'firefox >= 104',
81
73
  'safari >= 16'
82
- ], DEFAULT_ES_TARGET = 'es2022', DEFAULT_LIGHTNINGCSS_TARGET = browserslistToTargets(DEFAULT_BROWSERSLIST.map((item)=>item.replace(' >= ', ' '))), TEMPLATE_CONTENT = ({ title = '', headTag = '', mountId = '' })=>`<!DOCTYPE html>
74
+ ], DEFAULT_ES_TARGET = 'es2022', TEMPLATE_CONTENT = ({ title = '', headTag = '', mountId = '' })=>`<!DOCTYPE html>
83
75
  <html lang="en">
84
76
 
85
77
  <head>
@@ -196,7 +188,7 @@ let debounce = (fn, delay)=>{
196
188
  global[k] = performance.now();
197
189
  return;
198
190
  }
199
- msg && logger_logger.wait(`${msg} ${colors.dim('for')} ${colors.yellow(`${(performance.now() - global[k]).toFixed(2)}ms`)}`), global[k] = performance.now();
191
+ msg && console.log(` ${msg} ${colors.dim('in')} ${colors.yellow(`${(performance.now() - global[k]).toFixed(2)}ms`)}`), global[k] = performance.now();
200
192
  }, getPathInJs = (absPath)=>JSON.stringify(absPath).slice(1, -1), mergeConfig = merge, getUserDepVersion = (root, dep)=>{
201
193
  let depPath = getUserDepPath(root, dep);
202
194
  if (depPath) return JSON.parse(node_fs.readFileSync(node_path.resolve(depPath, 'package.json'), 'utf-8')).version;
@@ -249,10 +241,7 @@ let isCSSModules = ({ resourcePath, modules })=>{
249
241
  text = colors.yellow(message);
250
242
  break;
251
243
  case 'debug':
252
- text = `${colors.dim((()=>{
253
- let now = new Date(), hours = now.getHours().toString().padStart(2, '0'), minutes = now.getMinutes().toString().padStart(2, '0'), seconds = now.getSeconds().toString().padStart(2, '0');
254
- return `${hours}:${minutes}:${seconds}`;
255
- })())} ${colors.magenta('debug')} ${message}`;
244
+ text = `${colors.dim(getTime())} ${colors.magenta('debug')} ${message}`;
256
245
  break;
257
246
  default:
258
247
  text = message;
@@ -268,15 +257,15 @@ async function loadConfig({ cliOptions, command }) {
268
257
  let root = (null == cliOptions ? void 0 : cliOptions.root) ? node_path.resolve(cliOptions.root) : process.cwd(), configFilePath = resolveConfigPath(root, null == cliOptions ? void 0 : cliOptions.config), configExport = {};
269
258
  if (configFilePath) {
270
259
  if (isNodeVersionAtLeast(23, 6) || /\.(?:js|mjs|cjs)$/.test(configFilePath)) {
271
- logger_logger.debug('Loading config file with native loader:', colors.dim(configFilePath));
260
+ logger_logger.debug('loading config file with native loader:', colors.dim(configFilePath));
272
261
  try {
273
262
  let configFileURL = pathToFileURL(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
274
263
  configExport = exportModule.default ? exportModule.default : exportModule;
275
264
  } catch (err) {
276
- throw logger_logger.error(`Failed to load config file with native loader: ${colors.dim(configFilePath)}`), err;
265
+ throw logger_logger.error('failed to load config file with native loader:', colors.dim(configFilePath)), err;
277
266
  }
278
267
  } else {
279
- logger_logger.debug('Loading config file with jiti:', colors.dim(configFilePath));
268
+ logger_logger.debug('loading config file with jiti:', colors.dim(configFilePath));
280
269
  try {
281
270
  let jiti = createJiti(config_filename, {
282
271
  moduleCache: !1,
@@ -290,7 +279,7 @@ async function loadConfig({ cliOptions, command }) {
290
279
  default: !0
291
280
  });
292
281
  } catch (err) {
293
- throw logger_logger.error(`Failed to load config file with jiti: ${colors.dim(configFilePath)}`), err;
282
+ throw logger_logger.error('failed to load config file with jiti:', colors.dim(configFilePath)), err;
294
283
  }
295
284
  }
296
285
  if ('function' == typeof configExport) {
@@ -298,7 +287,7 @@ async function loadConfig({ cliOptions, command }) {
298
287
  env: getNodeEnv(),
299
288
  command: process.argv[2]
300
289
  };
301
- if (void 0 === (configExport = await configExport(params))) throw Error('Unpack config function must return a config object.');
290
+ if (void 0 === (configExport = await configExport(params))) throw Error('unpack config function must return a config object.');
302
291
  }
303
292
  }
304
293
  return (null == cliOptions ? void 0 : cliOptions.port) && setValueByPath(configExport, [
@@ -348,7 +337,7 @@ let isFileSync = (filePath)=>{
348
337
  return null == (_fs_statSync = node_fs.statSync(filePath, {
349
338
  throwIfNoEntry: !1
350
339
  })) ? void 0 : _fs_statSync.isFile();
351
- } catch (_) {
340
+ } catch {
352
341
  return !1;
353
342
  }
354
343
  };
@@ -399,8 +388,8 @@ async function getBuildDependencies(root, userBuildDependencies, envFilePaths) {
399
388
  async function applyCacheConfig({ config, unpackConfig, envFilePaths }) {
400
389
  var _unpackConfig_build, _unpackConfig_dev;
401
390
  if (!(null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.cache) || utils_isDevServer() && (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.lazyCompilation)) return config;
402
- let cacheConfig = isPlainObject(unpackConfig.build.cache) ? unpackConfig.build.cache : {}, isRspack = 'rspack' === unpackConfig.bundler, buildDependencies = await getBuildDependencies(unpackConfig.root, cacheConfig.buildDependencies || [], envFilePaths), cacheDirectory = cacheConfig.cacheDirectory;
403
- return cacheDirectory && (cacheDirectory = node_path.resolve(unpackConfig.root, cacheDirectory)), logger_logger.info('persistent cache enabled'), config = isRspack ? mergeConfig(config, {
391
+ let cacheConfig = isPlainObject(unpackConfig.build.cache) ? unpackConfig.build.cache : {}, buildDependencies = await getBuildDependencies(unpackConfig.root, cacheConfig.buildDependencies || [], envFilePaths), cacheDirectory = cacheConfig.cacheDirectory;
392
+ return cacheDirectory && (cacheDirectory = node_path.resolve(unpackConfig.root, cacheDirectory)), logger_logger.info('persistent cache enabled'), config = mergeConfig(config, {
404
393
  cache: !0,
405
394
  experiments: {
406
395
  cache: {
@@ -412,12 +401,6 @@ async function applyCacheConfig({ config, unpackConfig, envFilePaths }) {
412
401
  }
413
402
  }
414
403
  }
415
- }) : mergeConfig(config, {
416
- cache: {
417
- type: 'filesystem',
418
- buildDependencies,
419
- cacheDirectory
420
- }
421
404
  });
422
405
  }
423
406
  let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, SPLIT_STRATEGY_DISPATCHER = {
@@ -578,7 +561,6 @@ class TypedCssModulesPlugin {
578
561
  });
579
562
  }
580
563
  }
581
- var experimentCss_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
582
564
  function jsMinify_define_property(obj, key, value) {
583
565
  return key in obj ? Object.defineProperty(obj, key, {
584
566
  value: value,
@@ -587,19 +569,18 @@ function jsMinify_define_property(obj, key, value) {
587
569
  writable: !0
588
570
  }) : obj[key] = value, obj;
589
571
  }
590
- let { RawSource: jsMinify_RawSource, SourceMapSource: jsMinify_SourceMapSource } = webpack.sources, isJsFile = /\.[cm]?js(\?.*)?$/i, jsMinify_PLUGIN_NAME = 'JsMinifyPlugin';
572
+ let { RawSource, SourceMapSource } = rspack.sources, isJsFile = /\.[cm]?js(\?.*)?$/i, jsMinify_PLUGIN_NAME = 'JsMinifyPlugin';
591
573
  class JsMinifyPlugin {
592
574
  apply(compiler) {
593
575
  let meta = JSON.stringify({
594
576
  name: jsMinify_PLUGIN_NAME,
595
- version: "2.4.5",
577
+ version: "3.1.0",
596
578
  options: this.minifyOptions
597
579
  });
598
580
  compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
599
- compilation.hooks.chunkHash.tap(jsMinify_PLUGIN_NAME, (_, hash)=>hash.update(meta)), compilation.hooks.processAssets.tap({
581
+ compilation.hooks.chunkHash.tap(jsMinify_PLUGIN_NAME, (_, hash)=>hash.update(Buffer.from(meta))), compilation.hooks.processAssets.tap({
600
582
  name: jsMinify_PLUGIN_NAME,
601
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
602
- additionalAssets: !0
583
+ stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
603
584
  }, ()=>this.transformAssets(compilation)), compilation.hooks.statsPrinter.tap(jsMinify_PLUGIN_NAME, (stats)=>{
604
585
  stats.hooks.print.for('asset.info.minimized').tap(jsMinify_PLUGIN_NAME, (minimized, { green, formatFlag })=>minimized && green && formatFlag ? green(formatFlag('minimized')) : '');
605
586
  });
@@ -615,7 +596,7 @@ class JsMinifyPlugin {
615
596
  output.map && ((newMap = 'string' == typeof output.map ? JSON.parse(output.map) : output.map).sources = [
616
597
  asset.name
617
598
  ]);
618
- let newSource = sourceMap && newMap ? new jsMinify_SourceMapSource(output.code, asset.name, newMap, source, map, !0) : new jsMinify_RawSource(output.code), newInfo = {
599
+ let newSource = sourceMap && newMap ? new SourceMapSource(output.code, asset.name, newMap, source, map, !0) : new RawSource(output.code), newInfo = {
619
600
  ...asset.info,
620
601
  minimized: !0
621
602
  };
@@ -628,48 +609,6 @@ class JsMinifyPlugin {
628
609
  this.minify = (null == implementation ? void 0 : implementation.minify) ?? minify, this.minifyOptions = minifyOptions;
629
610
  }
630
611
  }
631
- function lightningcssMinify_define_property(obj, key, value) {
632
- return key in obj ? Object.defineProperty(obj, key, {
633
- value: value,
634
- enumerable: !0,
635
- configurable: !0,
636
- writable: !0
637
- }) : obj[key] = value, obj;
638
- }
639
- let lightningcssMinify_PLUGIN_NAME = 'LightningcssMinifyPlugin';
640
- class LightningcssMinifyPlugin {
641
- apply(compiler) {
642
- compiler.hooks.compilation.tap(lightningcssMinify_PLUGIN_NAME, (compilation)=>{
643
- compilation.hooks.processAssets.tap({
644
- name: lightningcssMinify_PLUGIN_NAME,
645
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
646
- }, ()=>this.transformAssets(compilation)), compilation.hooks.statsPrinter.tap(lightningcssMinify_PLUGIN_NAME, (statsPrinter)=>{
647
- statsPrinter.hooks.print.for('asset.info.minimized').tap(lightningcssMinify_PLUGIN_NAME, (minimized, { green, formatFlag })=>minimized && green && formatFlag ? green(formatFlag('minimized')) : '');
648
- });
649
- });
650
- }
651
- transformAssets(compilation) {
652
- let { options: { devtool }, webpack: { sources: { SourceMapSource, RawSource } } } = compilation.compiler, sourceMap = 'string' == typeof devtool && devtool.includes('source-map');
653
- compilation.getAssets().filter((asset)=>!asset.info.minimized && /\.css$/.test(asset.name)).map((asset)=>{
654
- let { source, map } = asset.source.sourceAndMap(), sourceAsString = source.toString(), code = 'string' == typeof source ? external_node_buffer_Buffer.from(source) : source, result = this.transform({
655
- filename: asset.name,
656
- code,
657
- minify: !0,
658
- sourceMap,
659
- ...this.transformOptions
660
- }), codeString = result.code.toString();
661
- compilation.updateAsset(asset.name, sourceMap ? new SourceMapSource(codeString, asset.name, JSON.parse(result.map.toString()), sourceAsString, map, !0) : new RawSource(codeString), {
662
- ...asset.info,
663
- minimized: !0
664
- });
665
- });
666
- }
667
- constructor(options = {}){
668
- lightningcssMinify_define_property(this, "transform", void 0), lightningcssMinify_define_property(this, "transformOptions", void 0);
669
- let { implementation, ...transformOptions } = options;
670
- this.transform = (null == implementation ? void 0 : implementation.transform) ?? transform, this.transformOptions = transformOptions;
671
- }
672
- }
673
612
  var oxlint_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
674
613
  function oxlint_define_property(obj, key, value) {
675
614
  return key in obj ? Object.defineProperty(obj, key, {
@@ -792,10 +731,7 @@ class ProgressBar {
792
731
  let { columns: terminalWidth } = process.stdout, current = originalCurrent;
793
732
  originalCurrent >= 0.98 && (current = 1);
794
733
  let loadingChar = this.loadingAnimation.getCurrentChar(), messageWidth = terminalWidth - this.prefix.length - (1 === current ? 10 : 9);
795
- logUpdate(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`);
796
- }
797
- done() {
798
- console.log();
734
+ logUpdate(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`), 1 === current && clearLine();
799
735
  }
800
736
  constructor(){
801
737
  progressBar_define_property(this, "prefix", 'transforming'), progressBar_define_property(this, "loadingAnimation", new LoadingAnimation());
@@ -859,6 +795,7 @@ async function printFileSize({ root, stats }) {
859
795
  chunkGroupMap.CSS.chunks.push(chunk);
860
796
  break;
861
797
  case '.js':
798
+ case '.wasm':
862
799
  chunkGroupMap.JS.chunks.push(chunk);
863
800
  break;
864
801
  default:
@@ -931,23 +868,23 @@ async function compileDone(compiler, stats) {
931
868
  logger_logger.ready(`built in ${prettyTime(compileTime)}${isDebug() ? ` (${stats.compilation.modules.size} modules)` : ''}`);
932
869
  }
933
870
  }
934
- let rspack_PLUGIN_NAME = 'ProgressPlugin';
871
+ let progress_PLUGIN_NAME = 'ProgressPlugin';
935
872
  class ProgressLiteRspackPlugin {
936
873
  apply(compiler) {
937
- compiler.hooks.watchRun.tap(rspack_PLUGIN_NAME, ()=>{
874
+ compiler.hooks.watchRun.tap(progress_PLUGIN_NAME, ()=>{
938
875
  (!utils_isDevServer() || global.__unpack_dev_server_started) && printDevLog(compiler, compiler.options.context);
939
- }), compiler.hooks.run.tap(rspack_PLUGIN_NAME, ()=>{
876
+ }), compiler.hooks.run.tap(progress_PLUGIN_NAME, ()=>{
940
877
  logger_logger.info('build started...');
941
- }), compiler.hooks.afterDone.tap(rspack_PLUGIN_NAME, async (stats)=>{
878
+ }), compiler.hooks.afterDone.tap(progress_PLUGIN_NAME, async (stats)=>{
942
879
  await compileDone(compiler, stats);
943
880
  });
944
881
  }
945
882
  }
946
883
  class ProgressRspackPlugin extends rspack.ProgressPlugin {
947
884
  apply(compiler) {
948
- super.apply(compiler), compiler.hooks.watchRun.tap(rspack_PLUGIN_NAME, ()=>{
885
+ super.apply(compiler), compiler.hooks.watchRun.tap(progress_PLUGIN_NAME, ()=>{
949
886
  (!utils_isDevServer() || global.__unpack_dev_server_started) && printDevLog(compiler, compiler.options.context);
950
- }), compiler.hooks.afterDone.tap(rspack_PLUGIN_NAME, async (stats)=>{
887
+ }), compiler.hooks.afterDone.tap(progress_PLUGIN_NAME, async (stats)=>{
951
888
  await compileDone(compiler, stats);
952
889
  });
953
890
  }
@@ -966,41 +903,10 @@ class ProgressRspackPlugin extends rspack.ProgressPlugin {
966
903
  }) : this[key] = value;
967
904
  }
968
905
  }
969
- function webpack_define_property(obj, key, value) {
970
- return key in obj ? Object.defineProperty(obj, key, {
971
- value: value,
972
- enumerable: !0,
973
- configurable: !0,
974
- writable: !0
975
- }) : obj[key] = value, obj;
976
- }
977
- let webpack_PLUGIN_NAME = 'ProgressPlugin';
978
- class ProgressWebpackPlugin extends webpack.ProgressPlugin {
979
- apply(compiler) {
980
- super.apply(compiler), compiler.hooks.watchRun.tap(webpack_PLUGIN_NAME, ()=>{
981
- (!utils_isDevServer() || global.__unpack_dev_server_started) && printDevLog(compiler, compiler.options.context);
982
- }), compiler.hooks.afterDone.tap(webpack_PLUGIN_NAME, async (stats)=>{
983
- this.isCompleted = !0, await compileDone(compiler, stats);
984
- });
985
- }
986
- constructor(){
987
- super({
988
- entries: !1,
989
- dependencies: !1,
990
- activeModules: !0,
991
- handler: isProd() ? (percentage, msg, ...args)=>{
992
- this.isCompleted || this.progressBar.update({
993
- current: percentage,
994
- message: `${msg} ${args.join(' ').replace(/(\d+) active /, '')}`
995
- });
996
- } : void 0
997
- }), webpack_define_property(this, "progressBar", new ProgressBar()), webpack_define_property(this, "isCompleted", !1);
998
- }
999
- }
1000
906
  let BundleAnalyzerPlugin = __webpack_require__("compiled/webpack-bundle-analyzer").BundleAnalyzerPlugin;
1001
907
  async function getBundlerConfig(unpackConfig) {
1002
- var _unpackConfig_build, _unpackConfig_build1, _minifyOptions_oxc, _unpackConfig_build2, _unpackConfig_build3, _unpackConfig_build4, _unpackConfig_build5, _unpackConfig_build6, _unpackConfig_build7, _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8, _unpackConfig_performance, _unpackConfig_performance1, _unpackConfig_build8, _unpackConfig_resolve, _unpackConfig_resolve1, _unpackConfig_dev, _unpackConfig_build9, _unpackConfig_experiments;
1003
- let define, isRspack = 'rspack' === unpackConfig.bundler, HtmlPlugin = isRspack ? rspack.HtmlRspackPlugin : html_webpack_plugin, IgnorePlugin = isRspack ? rspack.IgnorePlugin : webpack.IgnorePlugin, CopyPlugin = isRspack ? rspack.CopyRspackPlugin : copy_webpack_plugin, tsconfigPath = node_path.resolve(unpackConfig.root, 'tsconfig.json'), isTs = node_fs.existsSync(tsconfigPath), minifyOptions = isPlainObject(null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.minify) ? null == (_unpackConfig_build1 = unpackConfig.build) ? void 0 : _unpackConfig_build1.minify : {}, oxcMinifyCompress = isPlainObject(null == (_minifyOptions_oxc = minifyOptions.oxc) ? void 0 : _minifyOptions_oxc.compress) ? minifyOptions.oxc.compress : {}, ProgressPlugin = isRspack ? (null == (_unpackConfig_build2 = unpackConfig.build) ? void 0 : _unpackConfig_build2.progressBar) ? ProgressRspackPlugin : ProgressLiteRspackPlugin : ProgressWebpackPlugin, wasmFilename = 'js/[hash].module.wasm', { publicVars, filePaths: envFilePaths } = function({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
908
+ var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_build2, _unpackConfig_build3, _unpackConfig_build4, _unpackConfig_build5, _unpackConfig_build6, _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_performance, _unpackConfig_performance1, _unpackConfig_build7, _unpackConfig_resolve, _unpackConfig_resolve1, _unpackConfig_dev, _unpackConfig_build8, _unpackConfig_experiments;
909
+ let circularCount, tsconfigPath = node_path.resolve(unpackConfig.root, 'tsconfig.json'), isTs = node_fs.existsSync(tsconfigPath), minifyOptions = isPlainObject(null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.minify) ? null == (_unpackConfig_build1 = unpackConfig.build) ? void 0 : _unpackConfig_build1.minify : {}, ProgressPlugin = (null == (_unpackConfig_build2 = unpackConfig.build) ? void 0 : _unpackConfig_build2.progressBar) ? ProgressRspackPlugin : ProgressLiteRspackPlugin, { publicVars, filePaths: envFilePaths } = function({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
1004
910
  'PUBLIC_'
1005
911
  ], processEnv = process.env } = {}) {
1006
912
  if ('local' === mode) throw Error(`${colors.yellow('local')} cannot be used as a value for env mode, because ${colors.yellow('.env.local')} represents a temporary local file. Please use another value.`);
@@ -1055,64 +961,61 @@ async function getBundlerConfig(unpackConfig) {
1055
961
  stats: 'errors-only',
1056
962
  output: {
1057
963
  clean: !0,
1058
- path: node_path.resolve(unpackConfig.root, null == (_unpackConfig_build3 = unpackConfig.build) ? void 0 : _unpackConfig_build3.outDir),
964
+ path: node_path.resolve(unpackConfig.root, unpackConfig.build.outDir),
1059
965
  filename: getOutputFilename({
1060
966
  type: 'js',
1061
- hash: null == (_unpackConfig_build4 = unpackConfig.build) ? void 0 : _unpackConfig_build4.filenameHash
967
+ hash: null == (_unpackConfig_build3 = unpackConfig.build) ? void 0 : _unpackConfig_build3.filenameHash
1062
968
  }),
1063
969
  chunkFilename: getOutputFilename({
1064
970
  type: 'js',
1065
- hash: null == (_unpackConfig_build5 = unpackConfig.build) ? void 0 : _unpackConfig_build5.filenameHash,
971
+ hash: null == (_unpackConfig_build4 = unpackConfig.build) ? void 0 : _unpackConfig_build4.filenameHash,
1066
972
  async: !0
1067
973
  }),
1068
974
  crossOriginLoading: 'anonymous',
1069
975
  pathinfo: !1,
1070
- publicPath: null == (_unpackConfig_build6 = unpackConfig.build) ? void 0 : _unpackConfig_build6.publicPath,
1071
- webassemblyModuleFilename: wasmFilename,
976
+ publicPath: null == (_unpackConfig_build5 = unpackConfig.build) ? void 0 : _unpackConfig_build5.publicPath,
977
+ webassemblyModuleFilename: 'js/async/[hash].module.wasm',
1072
978
  assetModuleFilename: 'assets/[name].[contenthash:8][ext]'
1073
979
  },
1074
980
  infrastructureLogging: {
1075
981
  level: 'error'
1076
982
  },
1077
- devtool: null == (_unpackConfig_build7 = unpackConfig.build) ? void 0 : _unpackConfig_build7.sourceMap,
983
+ devtool: null == (_unpackConfig_build6 = unpackConfig.build) ? void 0 : _unpackConfig_build6.sourceMap,
1078
984
  module: {
1079
985
  rules: [
1080
986
  {
1081
- test: /\.(png|jpg|jpeg|gif)$/i,
987
+ test: /\.(png|jpe?g|gif|webp)$/i,
1082
988
  type: 'asset'
1083
989
  },
1084
990
  {
1085
- test: /\.(woff|woff2|eot|ttf|otf)$/i,
991
+ test: /\.(woff2?|eot|ttf|otf)$/i,
1086
992
  type: 'asset'
1087
993
  },
1088
994
  {
1089
995
  test: /\.wasm$/,
1090
996
  dependency: 'url',
1091
- type: 'asset/resource',
1092
- generator: {
1093
- filename: wasmFilename
1094
- }
997
+ type: 'asset/resource'
1095
998
  }
1096
999
  ]
1097
1000
  },
1098
1001
  plugins: [
1099
- (define = {
1002
+ new rspack.DefinePlugin({
1100
1003
  'import.meta.env.MODE': JSON.stringify(getNodeEnv()),
1101
1004
  'import.meta.env.DEV': isDev(),
1102
1005
  'import.meta.env.PROD': isProd(),
1103
1006
  ...publicVars,
1104
1007
  ...unpackConfig.define
1105
- }, isRspack ? new rspack.DefinePlugin(define) : new webpack.DefinePlugin(define)),
1106
- !unpackConfig.mpa && new HtmlPlugin({
1107
- template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || (isRspack ? void 0 : ''),
1108
- templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? !!isRspack && void 0 : TEMPLATE_CONTENT),
1008
+ }),
1009
+ !unpackConfig.mpa && new rspack.HtmlRspackPlugin({
1010
+ template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
1011
+ templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : TEMPLATE_CONTENT),
1109
1012
  templateParameters: {
1110
- mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
1111
- title: isFunction(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
1013
+ mountId: unpackConfig.html.mountId,
1014
+ title: isFunction(null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.title) ? null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title({
1112
1015
  entryName: 'index'
1113
- }) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
1114
- headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
1115
- ...null == (_unpackConfig_html8 = unpackConfig.html) ? void 0 : _unpackConfig_html8.templateParameters
1016
+ }) : (null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title) || '',
1017
+ headTag: (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.headTag) || '',
1018
+ ...null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.templateParameters
1116
1019
  },
1117
1020
  minify: !1,
1118
1021
  chunks: [
@@ -1122,11 +1025,11 @@ async function getBundlerConfig(unpackConfig) {
1122
1025
  (null == (_unpackConfig_performance = unpackConfig.performance) ? void 0 : _unpackConfig_performance.bundleAnalyze) && isProd() && new BundleAnalyzerPlugin({
1123
1026
  analyzerPort: 'auto'
1124
1027
  }),
1125
- (null == (_unpackConfig_performance1 = unpackConfig.performance) ? void 0 : _unpackConfig_performance1.removeMomentLocale) && new IgnorePlugin({
1028
+ (null == (_unpackConfig_performance1 = unpackConfig.performance) ? void 0 : _unpackConfig_performance1.removeMomentLocale) && new rspack.IgnorePlugin({
1126
1029
  resourceRegExp: /^\.\/locale$/,
1127
1030
  contextRegExp: /moment$/
1128
1031
  }),
1129
- (null == (_unpackConfig_build8 = unpackConfig.build) ? void 0 : _unpackConfig_build8.copy) && new CopyPlugin({
1032
+ (null == (_unpackConfig_build7 = unpackConfig.build) ? void 0 : _unpackConfig_build7.copy) && new rspack.CopyRspackPlugin({
1130
1033
  patterns: unpackConfig.build.copy
1131
1034
  }),
1132
1035
  unpackConfig.typeCheck && isDev() && isTs && new TsCheckerRspackPlugin({
@@ -1155,17 +1058,52 @@ async function getBundlerConfig(unpackConfig) {
1155
1058
  }
1156
1059
  }),
1157
1060
  new ProgressPlugin(),
1158
- unpackConfig.lint && new OxlintPlugin()
1061
+ unpackConfig.lint && new OxlintPlugin(),
1062
+ unpackConfig.detectCircular && (circularCount = 0, new rspack.CircularDependencyRspackPlugin({
1063
+ exclude: /node_modules/,
1064
+ onStart () {
1065
+ circularCount = 0;
1066
+ },
1067
+ onDetected (_, modules) {
1068
+ circularCount++, console.log(''), logger_logger.warn('circular dependency detected:');
1069
+ let uniquePaths = modules.map((module)=>{
1070
+ let filePath = module.replace(/^.*!/, ''), relativePath = node_path.relative(unpackConfig.root, filePath);
1071
+ return relativePath.startsWith('..') ? filePath : relativePath;
1072
+ }).slice(0, -1);
1073
+ if (2 + uniquePaths.join(" \u2192 ").length > (process.stdout.columns || 80)) {
1074
+ console.log('');
1075
+ let arrow = "\u21B3 ", lastIndex = uniquePaths.length - 1;
1076
+ uniquePaths.forEach((p, i)=>{
1077
+ switch(i){
1078
+ case 0:
1079
+ console.log(` ${p}`);
1080
+ break;
1081
+ case lastIndex:
1082
+ console.log(` ${arrow}${p} ${colors.dim('(cycle introduced)')}`);
1083
+ break;
1084
+ default:
1085
+ console.log(` ${arrow}${p}`);
1086
+ }
1087
+ }), console.log(` ${arrow}${uniquePaths[0]}`), console.log('');
1088
+ } else {
1089
+ let line1 = ' ', downArrowPos = 0;
1090
+ uniquePaths.forEach((p, i)=>{
1091
+ line1 += p, i < uniquePaths.length - 1 ? line1 += " \u2192 " : downArrowPos = line1.length - 1;
1092
+ });
1093
+ let lineLength = downArrowPos - 2;
1094
+ console.log(''), console.log(line1), console.log(' ' + ' '.repeat(0) + "\u2191" + ' '.repeat(downArrowPos - 2 - 1) + "\u2193"), console.log(' ' + ' '.repeat(0) + "\u2514" + "\u2500".repeat(lineLength - 1) + "\u2518"), console.log('');
1095
+ }
1096
+ },
1097
+ onEnd () {
1098
+ circularCount > 0 && console.log(`Found ${circularCount} circular ${1 === circularCount ? 'dependency' : 'dependencies'}.`);
1099
+ }
1100
+ }))
1159
1101
  ].filter(Boolean),
1160
1102
  externals: unpackConfig.externals,
1161
1103
  resolve: {
1104
+ tsConfig: isTs ? tsconfigPath : void 0,
1162
1105
  alias: {
1163
1106
  '@': node_path.resolve(unpackConfig.root, 'src'),
1164
- ...isTs ? (()=>{
1165
- var _json5_parse_compilerOptions, _json5_parse;
1166
- let paths = null == (_json5_parse = json5.parse(node_fs.readFileSync(tsconfigPath, 'utf-8'))) || null == (_json5_parse_compilerOptions = _json5_parse.compilerOptions) ? void 0 : _json5_parse_compilerOptions.paths;
1167
- return paths ? Object.keys(paths).reduce((acc, key)=>(acc[key.replace(/\/\*$/, '')] = node_path.resolve(unpackConfig.root, paths[key][0].replace(/\/\*$/, '')), acc), {}) : {};
1168
- })() : {},
1169
1107
  ...null == (_unpackConfig_resolve = unpackConfig.resolve) ? void 0 : _unpackConfig_resolve.alias
1170
1108
  },
1171
1109
  extensionAlias: {
@@ -1199,19 +1137,18 @@ async function getBundlerConfig(unpackConfig) {
1199
1137
  },
1200
1138
  optimization: {
1201
1139
  moduleIds: isDev() ? 'named' : 'deterministic',
1202
- minimize: !!(null == (_unpackConfig_build9 = unpackConfig.build) ? void 0 : _unpackConfig_build9.minify),
1140
+ minimize: !!(null == (_unpackConfig_build8 = unpackConfig.build) ? void 0 : _unpackConfig_build8.minify),
1203
1141
  minimizer: [
1204
- new JsMinifyPlugin({
1205
- ...minifyOptions.oxc,
1142
+ new JsMinifyPlugin(mergeConfig({
1206
1143
  compress: {
1207
- target: DEFAULT_ES_TARGET,
1208
- ...oxcMinifyCompress
1144
+ target: DEFAULT_ES_TARGET
1209
1145
  }
1210
- }),
1211
- new LightningcssMinifyPlugin({
1212
- targets: DEFAULT_LIGHTNINGCSS_TARGET,
1213
- ...minifyOptions.lightningcss
1214
- })
1146
+ }, minifyOptions.oxc || {})),
1147
+ new rspack.LightningCssMinimizerRspackPlugin(mergeConfig({
1148
+ minimizerOptions: {
1149
+ targets: DEFAULT_BROWSERSLIST
1150
+ }
1151
+ }, minifyOptions.lightningcss || {}))
1215
1152
  ]
1216
1153
  },
1217
1154
  watchOptions: {
@@ -1249,7 +1186,7 @@ async function getBundlerConfig(unpackConfig) {
1249
1186
  return config;
1250
1187
  })({
1251
1188
  config: config = (null == (_unpackConfig_experiments = unpackConfig.experiments) ? void 0 : _unpackConfig_experiments.css) ? function({ config, unpackConfig }) {
1252
- var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_css, _unpackConfig_css1, _config_module_rules, _config_module, _config_module_rules1, _config_module1, _config_module_rules2, _config_module2;
1189
+ var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_css, _unpackConfig_css1;
1253
1190
  config.output.cssFilename = getOutputFilename({
1254
1191
  type: 'css',
1255
1192
  hash: null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.filenameHash
@@ -1302,33 +1239,14 @@ async function getBundlerConfig(unpackConfig) {
1302
1239
  sourceMap
1303
1240
  }
1304
1241
  };
1305
- };
1306
- null == (_config_module = config.module) || null == (_config_module_rules = _config_module.rules) || _config_module_rules.push({
1307
- test: /\.less$/i,
1308
- oneOf: [
1309
- withCssModules({
1310
- use: [
1311
- getThreadLoader(),
1312
- getLessLoader()
1313
- ].filter(Boolean)
1314
- }),
1315
- {
1316
- use: [
1317
- getThreadLoader(),
1318
- getLessLoader()
1319
- ].filter(Boolean),
1320
- type: 'css'
1321
- }
1322
- ].filter(Boolean)
1323
- });
1324
- let getCssLoader = ()=>{
1242
+ }, getCssLoader = ()=>{
1325
1243
  var _unpackConfig_css, _unpackConfig_css1, _unpackConfig_css2;
1326
1244
  return (null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.transformer) === 'lightningcss' ? {
1327
- loader: node_path.resolve(experimentCss_dirname, './lightningcssLoader.mjs'),
1328
- options: mergeConfig((null == (_unpackConfig_css1 = unpackConfig.css) ? void 0 : _unpackConfig_css1.lightningcss) || {}, {
1329
- sourceMap,
1330
- targets: DEFAULT_LIGHTNINGCSS_TARGET
1331
- })
1245
+ loader: 'builtin:lightningcss-loader',
1246
+ options: {
1247
+ targets: DEFAULT_BROWSERSLIST,
1248
+ ...null == (_unpackConfig_css1 = unpackConfig.css) ? void 0 : _unpackConfig_css1.lightningcss
1249
+ }
1332
1250
  } : {
1333
1251
  loader: getCompiledPkgPath('postcss-loader'),
1334
1252
  options: {
@@ -1336,8 +1254,22 @@ async function getBundlerConfig(unpackConfig) {
1336
1254
  sourceMap
1337
1255
  }
1338
1256
  };
1257
+ }, getSassLoader = ()=>{
1258
+ var _unpackConfig_css;
1259
+ return {
1260
+ loader: getCompiledPkgPath('sass-loader'),
1261
+ options: {
1262
+ api: 'modern-compiler',
1263
+ implementation: getUserDepPath(unpackConfig.root, [
1264
+ 'sass-embedded',
1265
+ 'sass'
1266
+ ]),
1267
+ sassOptions: null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.sass,
1268
+ sourceMap
1269
+ }
1270
+ };
1339
1271
  };
1340
- null == (_config_module1 = config.module) || null == (_config_module_rules1 = _config_module1.rules) || _config_module_rules1.push({
1272
+ return config.module.rules.push({
1341
1273
  test: /\.css$/i,
1342
1274
  oneOf: [
1343
1275
  withCssModules({
@@ -1352,32 +1284,37 @@ async function getBundlerConfig(unpackConfig) {
1352
1284
  type: 'css'
1353
1285
  }
1354
1286
  ].filter(Boolean)
1355
- });
1356
- let getSassLoader = ()=>{
1357
- var _unpackConfig_css;
1358
- return {
1359
- loader: getCompiledPkgPath('sass-loader'),
1360
- options: {
1361
- api: 'modern-compiler',
1362
- implementation: getUserDepPath(unpackConfig.root, [
1363
- 'sass-embedded',
1364
- 'sass'
1365
- ]),
1366
- sassOptions: null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.sass,
1367
- sourceMap
1287
+ }), config.module.rules.push({
1288
+ test: /\.less$/i,
1289
+ oneOf: [
1290
+ withCssModules({
1291
+ use: [
1292
+ getCssLoader(),
1293
+ getThreadLoader(),
1294
+ getLessLoader()
1295
+ ].filter(Boolean)
1296
+ }),
1297
+ {
1298
+ use: [
1299
+ getCssLoader(),
1300
+ getThreadLoader(),
1301
+ getLessLoader()
1302
+ ].filter(Boolean),
1303
+ type: 'css'
1368
1304
  }
1369
- };
1370
- };
1371
- return null == (_config_module2 = config.module) || null == (_config_module_rules2 = _config_module2.rules) || _config_module_rules2.push({
1305
+ ].filter(Boolean)
1306
+ }), config.module.rules.push({
1372
1307
  test: /\.s[ac]ss$/i,
1373
1308
  oneOf: [
1374
1309
  withCssModules({
1375
1310
  use: [
1311
+ getCssLoader(),
1376
1312
  getSassLoader()
1377
1313
  ]
1378
1314
  }),
1379
1315
  {
1380
1316
  use: [
1317
+ getCssLoader(),
1381
1318
  getSassLoader()
1382
1319
  ],
1383
1320
  type: 'css'
@@ -1390,14 +1327,14 @@ async function getBundlerConfig(unpackConfig) {
1390
1327
  config,
1391
1328
  unpackConfig
1392
1329
  }) : function({ config, unpackConfig }) {
1393
- var _unpackConfig_css, _unpackConfig_css1, _unpackConfig_build, _unpackConfig_css2, _config_module_rules, _config_module, _config_module_rules1, _config_module1, _unpackConfig_css3, _config_module_rules2, _config_module2, _unpackConfig_build1, _unpackConfig_build2, _unpackConfig_css4, _unpackConfig_css5, _unpackConfig_css6;
1394
- let CssExtractPlugin = 'rspack' === unpackConfig.bundler ? rspack.CssExtractRspackPlugin : mini_css_extract_plugin, sourceMap = null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.sourceMap, modules = null == (_unpackConfig_css1 = unpackConfig.css) ? void 0 : _unpackConfig_css1.modules;
1330
+ var _unpackConfig_css, _unpackConfig_css1, _unpackConfig_build, _unpackConfig_css2, _unpackConfig_css3, _unpackConfig_build1, _unpackConfig_build2;
1331
+ let sourceMap = null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.sourceMap, modules = null == (_unpackConfig_css1 = unpackConfig.css) ? void 0 : _unpackConfig_css1.modules;
1395
1332
  isPlainObject(modules) || !1 === modules || (modules = {});
1396
1333
  let getCommonRules = ({ importLoaders })=>[
1397
1334
  utils_isDevServer() ? {
1398
1335
  loader: getCompiledPkgPath('style-loader')
1399
1336
  } : {
1400
- loader: CssExtractPlugin.loader,
1337
+ loader: rspack.CssExtractRspackPlugin.loader,
1401
1338
  options: {
1402
1339
  defaultExport: !0
1403
1340
  }
@@ -1426,7 +1363,7 @@ async function getBundlerConfig(unpackConfig) {
1426
1363
  }
1427
1364
  }
1428
1365
  ].filter(Boolean);
1429
- return utils_isDevServer() || config.plugins.push(new CssExtractPlugin({
1366
+ utils_isDevServer() || config.plugins.push(new rspack.CssExtractRspackPlugin({
1430
1367
  filename: getOutputFilename({
1431
1368
  type: 'css',
1432
1369
  hash: null == (_unpackConfig_build1 = unpackConfig.build) ? void 0 : _unpackConfig_build1.filenameHash
@@ -1435,13 +1372,32 @@ async function getBundlerConfig(unpackConfig) {
1435
1372
  type: 'css',
1436
1373
  hash: null == (_unpackConfig_build2 = unpackConfig.build) ? void 0 : _unpackConfig_build2.filenameHash,
1437
1374
  async: !0
1438
- })
1439
- })), null == (_config_module = config.module) || null == (_config_module_rules = _config_module.rules) || _config_module_rules.push({
1375
+ }),
1376
+ ignoreOrder: !0
1377
+ }));
1378
+ let getCssLoader = ()=>{
1379
+ var _unpackConfig_css, _unpackConfig_css1, _unpackConfig_css2;
1380
+ return (null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.transformer) === 'lightningcss' ? {
1381
+ loader: 'builtin:lightningcss-loader',
1382
+ options: {
1383
+ targets: DEFAULT_BROWSERSLIST,
1384
+ ...null == (_unpackConfig_css1 = unpackConfig.css) ? void 0 : _unpackConfig_css1.lightningcss
1385
+ }
1386
+ } : {
1387
+ loader: getCompiledPkgPath('postcss-loader'),
1388
+ options: {
1389
+ postcssOptions: null == (_unpackConfig_css2 = unpackConfig.css) ? void 0 : _unpackConfig_css2.postcss,
1390
+ sourceMap
1391
+ }
1392
+ };
1393
+ };
1394
+ return config.module.rules.push({
1440
1395
  test: /\.less$/i,
1441
1396
  use: [
1442
1397
  ...getCommonRules({
1443
- importLoaders: 1
1398
+ importLoaders: 2
1444
1399
  }),
1400
+ getCssLoader(),
1445
1401
  (null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.parallel) && isProd() && {
1446
1402
  loader: require.resolve('thread-loader'),
1447
1403
  options: THREAD_OPTIONS
@@ -1457,32 +1413,21 @@ async function getBundlerConfig(unpackConfig) {
1457
1413
  }
1458
1414
  }
1459
1415
  ].filter(Boolean)
1460
- }), null == (_config_module1 = config.module) || null == (_config_module_rules1 = _config_module1.rules) || _config_module_rules1.push({
1416
+ }), config.module.rules.push({
1461
1417
  test: /\.css$/i,
1462
1418
  use: [
1463
1419
  ...getCommonRules({
1464
1420
  importLoaders: 1
1465
1421
  }),
1466
- (null == (_unpackConfig_css4 = unpackConfig.css) ? void 0 : _unpackConfig_css4.transformer) === 'lightningcss' ? {
1467
- loader: node_path.resolve(css_dirname, './lightningcssLoader.mjs'),
1468
- options: mergeConfig((null == (_unpackConfig_css5 = unpackConfig.css) ? void 0 : _unpackConfig_css5.lightningcss) || {}, {
1469
- sourceMap,
1470
- targets: DEFAULT_LIGHTNINGCSS_TARGET
1471
- })
1472
- } : {
1473
- loader: getCompiledPkgPath('postcss-loader'),
1474
- options: {
1475
- postcssOptions: null == (_unpackConfig_css6 = unpackConfig.css) ? void 0 : _unpackConfig_css6.postcss,
1476
- sourceMap
1477
- }
1478
- }
1422
+ getCssLoader()
1479
1423
  ]
1480
- }), null == (_config_module2 = config.module) || null == (_config_module_rules2 = _config_module2.rules) || _config_module_rules2.push({
1424
+ }), config.module.rules.push({
1481
1425
  test: /\.s[ac]ss$/i,
1482
1426
  use: [
1483
1427
  ...getCommonRules({
1484
- importLoaders: 1
1428
+ importLoaders: 2
1485
1429
  }),
1430
+ getCssLoader(),
1486
1431
  {
1487
1432
  loader: getCompiledPkgPath('sass-loader'),
1488
1433
  options: {
@@ -1516,7 +1461,7 @@ async function getBundlerConfig(unpackConfig) {
1516
1461
  }) : mergeConfig(config, unpackConfig.bundlerConfig)), config;
1517
1462
  }
1518
1463
  async function unpackBuild(unpackConfig) {
1519
- let compiler = ('rspack' === unpackConfig.bundler ? rspack : webpack)(await getBundlerConfig(unpackConfig)), handler = (err, stats)=>{
1464
+ let compiler = rspack(await getBundlerConfig(unpackConfig)), handler = (err, stats)=>{
1520
1465
  if (err) {
1521
1466
  console.error(err.stack || err), err.details && console.error(err.details);
1522
1467
  return;
@@ -1549,7 +1494,38 @@ async function openBrowser(url) {
1549
1494
  logger_logger.error(err);
1550
1495
  }
1551
1496
  try {
1552
- return open_0(url).catch(()=>{}), !0;
1497
+ return new Promise((resolve, reject)=>{
1498
+ let command, args = [];
1499
+ switch(platform()){
1500
+ case 'darwin':
1501
+ command = 'open', args = [
1502
+ url
1503
+ ];
1504
+ break;
1505
+ case 'win32':
1506
+ command = 'cmd', args = [
1507
+ '/c',
1508
+ 'start',
1509
+ '',
1510
+ url
1511
+ ];
1512
+ break;
1513
+ default:
1514
+ command = 'xdg-open', args = [
1515
+ url
1516
+ ];
1517
+ }
1518
+ let child = spawn(command, args, {
1519
+ stdio: 'ignore',
1520
+ detached: !0,
1521
+ windowsHide: !0
1522
+ });
1523
+ child.on('error', (error)=>{
1524
+ reject(Error(`Failed to open URL: ${error.message}`));
1525
+ }), child.on('spawn', ()=>{
1526
+ resolve();
1527
+ }), child.unref();
1528
+ }).catch(()=>{}), !0;
1553
1529
  } catch (err) {
1554
1530
  return logger_logger.error(err), !1;
1555
1531
  }
@@ -1733,7 +1709,7 @@ let getExternalLibraryName = (pkgName)=>({
1733
1709
  let port = await getPort(), staticServer = app.listen(port, ()=>{});
1734
1710
  restartCleaners.push(()=>new Promise((resolve)=>staticServer.close(()=>resolve())));
1735
1711
  let externals = {}, jsAssets = [], cssAssets = [], preJsAssets = [];
1736
- bundledDeps.filter(Boolean).forEach((dep)=>{
1712
+ return bundledDeps.filter(Boolean).forEach((dep)=>{
1737
1713
  dep && (externals[dep.name] = getExternalValue(dep.name), dep.assets.forEach((absPath)=>{
1738
1714
  let relativePath = node_path.relative(cachePath, absPath), preDeps = [
1739
1715
  'react',
@@ -1757,16 +1733,14 @@ let getExternalLibraryName = (pkgName)=>({
1757
1733
  ] : {
1758
1734
  ...externals,
1759
1735
  ...unpackConfig.externals
1760
- };
1761
- let HtmlPlugin = 'rspack' === unpackConfig.bundler ? rspack.HtmlRspackPlugin : html_webpack_plugin;
1762
- return unpackConfig.plugins.push({
1736
+ }, unpackConfig.plugins.push({
1763
1737
  name: 'unpack:prebundle',
1764
1738
  bundlerConfig: (config)=>{
1765
1739
  let PLUGIN_NAME = 'PluginInjectAssets';
1766
1740
  return config.plugins.push({
1767
1741
  apply: (compiler)=>{
1768
1742
  compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
1769
- HtmlPlugin.getCompilationHooks(compilation).beforeAssetTagGeneration.tapPromise(PLUGIN_NAME, async (args)=>{
1743
+ rspack.HtmlRspackPlugin.getCompilationHooks(compilation).beforeAssetTagGeneration.tapPromise(PLUGIN_NAME, async (args)=>{
1770
1744
  let sortedPreJsAssets = preJsAssets.sort((a, b)=>a.order - b.order).map((item)=>item.path);
1771
1745
  return args.assets.js.unshift(...sortedPreJsAssets, ...jsAssets), args.assets.css.unshift(...cssAssets), args;
1772
1746
  });
@@ -1778,11 +1752,11 @@ let getExternalLibraryName = (pkgName)=>({
1778
1752
  };
1779
1753
  async function unpackDev(originalUnpackConfig) {
1780
1754
  var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1, _unpackConfig_server2;
1781
- let unpackConfig = originalUnpackConfig, isRspack = 'rspack' === unpackConfig.bundler, bundler = isRspack ? rspack : webpack;
1755
+ let unpackConfig = originalUnpackConfig;
1782
1756
  (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.prebundle) && (unpackConfig = await prebundleDeps({
1783
1757
  unpackConfig
1784
1758
  }));
1785
- let compiler = bundler(await getBundlerConfig(unpackConfig)), port = await getPort(null == (_unpackConfig_server = unpackConfig.server) ? void 0 : _unpackConfig_server.port), proxyConfig = null == (_unpackConfig_server1 = unpackConfig.server) ? void 0 : _unpackConfig_server1.proxy;
1759
+ let compiler = rspack(await getBundlerConfig(unpackConfig)), port = await getPort(null == (_unpackConfig_server = unpackConfig.server) ? void 0 : _unpackConfig_server.port), proxyConfig = null == (_unpackConfig_server1 = unpackConfig.server) ? void 0 : _unpackConfig_server1.proxy;
1786
1760
  isPlainObject(proxyConfig) && (proxyConfig = Object.entries(proxyConfig).map(([contextStr, target])=>({
1787
1761
  context: contextStr.split(','),
1788
1762
  target,
@@ -1803,9 +1777,9 @@ async function unpackDev(originalUnpackConfig) {
1803
1777
  devServerOptions.setupMiddlewares = (middlewares)=>(middlewares.unshift((req, _, next)=>{
1804
1778
  var _req_headers_accept;
1805
1779
  (null == (_req_headers_accept = req.headers.accept) ? void 0 : _req_headers_accept.includes('html')) && (req.url = '/index.html'), next();
1806
- }), isRspack && middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
1780
+ }), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
1807
1781
  let server = new webpack_dev_server(devServerOptions, compiler);
1808
- await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v2.4.5`)} ${colors.dim(`ready in ${colors.reset(Math.ceil(performance.now() - global.__unpack_start_time))}ms`)}\n`), getAddressUrls({
1782
+ await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.1.0`)} ${colors.dim(`ready in ${colors.reset(Math.ceil(performance.now() - global.__unpack_start_time))}ms`)}\n`), getAddressUrls({
1809
1783
  port: port
1810
1784
  }).forEach((addr)=>{
1811
1785
  let url;
@@ -1822,7 +1796,6 @@ async function unpackDev(originalUnpackConfig) {
1822
1796
  function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
1823
1797
  let resolveConfig = async ()=>{
1824
1798
  let defaultConfig = {
1825
- bundler: 'rspack',
1826
1799
  root: cwd,
1827
1800
  build: {
1828
1801
  outDir: 'dist',
@@ -1856,7 +1829,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
1856
1829
  ]
1857
1830
  }, _context = {
1858
1831
  callerName,
1859
- version: "2.4.5"
1832
+ version: "3.1.0"
1860
1833
  }, { plugins, bundlerConfig, ...rest } = mergeConfig(defaultConfig, config);
1861
1834
  for (let plugin of getNormalizedPluginsByHook('config', plugins))rest = await plugin.config(rest, {
1862
1835
  ..._context,
@@ -1871,10 +1844,9 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
1871
1844
  };
1872
1845
  return {
1873
1846
  build: async ({ watch } = {})=>{
1874
- var _config_build;
1875
1847
  setNodeEnv(watch ? 'development' : 'production');
1876
1848
  let config = await resolveConfig();
1877
- console.log(colors.rainbow(`${callerName} v2.4.5`), colors.green(`building:${watch ? 'development' : 'production'}`), colors.dim(`\u{279C} ${null == (_config_build = config.build) ? void 0 : _config_build.outDir}`)), unpackBuild(config);
1849
+ console.log(colors.rainbow(`${callerName} v3.1.0`), colors.green(`building for ${getNodeEnv()}...`)), unpackBuild(config);
1878
1850
  },
1879
1851
  dev: async ()=>{
1880
1852
  global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0), unpackDev(await resolveConfig());
@@ -1894,4 +1866,4 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
1894
1866
  ...options
1895
1867
  });
1896
1868
  }
1897
- export { CSS_MODULES_LOCAL_IDENT_NAME, CSS_MODULES_REGEX, CSS_NAMED_EXPORT, DEFAULT_BROWSERSLIST, DEFAULT_DEV_HOST, DEFAULT_ES_TARGET, DEFAULT_LIGHTNINGCSS_TARGET, DEV_DEFAULT_FILENAME, EXPORT_LOCALS_CONVENTION, html_webpack_plugin as HtmlWebpackPlugin, logger_LogColor as LogColor, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, TEMPLATE_CONTENT, TEMP_DIR, THREAD_OPTIONS, clearLine, colors, createChokidar, createUnpack, debounce, defineConfig, 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, loadConfig, logUpdate, logger_logger as logger, mergeConfig, pathExists, prettyTime, removeDir, resolveConfigPath, restartCleaners, rspack, setDevServer, setNodeEnv, setValueByPath, trackPerformance, webpack };
1869
+ export { CSS_MODULES_LOCAL_IDENT_NAME, CSS_MODULES_REGEX, CSS_NAMED_EXPORT, DEFAULT_BROWSERSLIST, DEFAULT_DEV_HOST, DEFAULT_ES_TARGET, DEV_DEFAULT_FILENAME, EXPORT_LOCALS_CONVENTION, logger_LogColor as LogColor, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, TEMPLATE_CONTENT, TEMP_DIR, THREAD_OPTIONS, clearLine, colors, createChokidar, createUnpack, debounce, defineConfig, 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, loadConfig, logUpdate, logger_logger as logger, mergeConfig, pathExists, prettyTime, removeDir, resolveConfigPath, restartCleaners, rspack, setDevServer, setNodeEnv, setValueByPath, trackPerformance };