@unpackjs/core 4.4.0 → 4.6.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 (90) hide show
  1. package/compiled/css-loader/index.js +20 -20
  2. package/compiled/css-loader/package.json +1 -1
  3. package/compiled/launch-editor/index.js +19 -12
  4. package/compiled/launch-editor/package.json +1 -1
  5. package/compiled/less-loader/index.js +8 -8
  6. package/compiled/postcss-loader/index.js +114 -110
  7. package/compiled/postcss-loader/package.json +1 -1
  8. package/compiled/sass-loader/index.js +8 -8
  9. package/dist/index.js +269 -425
  10. package/dist-types/cli/injectFramework.d.ts +1 -1
  11. package/dist-types/cli/injectFramework.d.ts.map +1 -1
  12. package/dist-types/createUnpack.d.ts.map +1 -1
  13. package/dist-types/plugins/prebundle.d.ts.map +1 -1
  14. package/dist-types/plugins/splitChunks.d.ts +3 -0
  15. package/dist-types/plugins/splitChunks.d.ts.map +1 -0
  16. package/dist-types/plugins/svgIcons.d.ts +2 -8
  17. package/dist-types/plugins/svgIcons.d.ts.map +1 -1
  18. package/dist-types/plugins/unocss.d.ts +2 -5
  19. package/dist-types/plugins/unocss.d.ts.map +1 -1
  20. package/dist-types/progressBar.d.ts +2 -4
  21. package/dist-types/progressBar.d.ts.map +1 -1
  22. package/dist-types/rspack-config/buildAnalyze.d.ts +6 -0
  23. package/dist-types/rspack-config/buildAnalyze.d.ts.map +1 -0
  24. package/dist-types/rspack-config/cache.d.ts +7 -0
  25. package/dist-types/rspack-config/cache.d.ts.map +1 -0
  26. package/dist-types/rspack-config/css.d.ts +6 -0
  27. package/dist-types/rspack-config/css.d.ts.map +1 -0
  28. package/dist-types/rspack-config/detectCircular.d.ts +6 -0
  29. package/dist-types/rspack-config/detectCircular.d.ts.map +1 -0
  30. package/dist-types/rspack-config/helpers.d.ts +54 -0
  31. package/dist-types/rspack-config/helpers.d.ts.map +1 -0
  32. package/dist-types/rspack-config/html.d.ts +6 -0
  33. package/dist-types/rspack-config/html.d.ts.map +1 -0
  34. package/dist-types/rspack-config/index.d.ts +3 -0
  35. package/dist-types/rspack-config/index.d.ts.map +1 -0
  36. package/dist-types/rspack-config/loaders/transformLoader.d.ts.map +1 -0
  37. package/dist-types/rspack-config/loaders/typedCssModulesLoader.d.ts.map +1 -0
  38. package/dist-types/rspack-config/nativeCss.d.ts +6 -0
  39. package/dist-types/rspack-config/nativeCss.d.ts.map +1 -0
  40. package/dist-types/rspack-config/plugins/jsMinify.d.ts.map +1 -0
  41. package/dist-types/rspack-config/plugins/progress/helpers.d.ts.map +1 -0
  42. package/dist-types/rspack-config/plugins/progress/index.d.ts.map +1 -0
  43. package/dist-types/{bundler-config → rspack-config}/plugins/registerHooks.d.ts +0 -1
  44. package/dist-types/rspack-config/plugins/registerHooks.d.ts.map +1 -0
  45. package/dist-types/rspack-config/typeCheck.d.ts +6 -0
  46. package/dist-types/rspack-config/typeCheck.d.ts.map +1 -0
  47. package/dist-types/run/dev.d.ts.map +1 -1
  48. package/dist-types/types/config.d.ts +25 -21
  49. package/dist-types/types/config.d.ts.map +1 -1
  50. package/dist-types/types/index.d.ts +0 -1
  51. package/dist-types/types/index.d.ts.map +1 -1
  52. package/dist-types/types/plugin.d.ts +5 -6
  53. package/dist-types/types/plugin.d.ts.map +1 -1
  54. package/dist-types/types/thirdParty.d.ts.map +1 -1
  55. package/package.json +9 -8
  56. package/dist-types/bundler-config/buildAnalyze.d.ts +0 -6
  57. package/dist-types/bundler-config/buildAnalyze.d.ts.map +0 -1
  58. package/dist-types/bundler-config/cache.d.ts +0 -7
  59. package/dist-types/bundler-config/cache.d.ts.map +0 -1
  60. package/dist-types/bundler-config/chunkSplit.d.ts +0 -6
  61. package/dist-types/bundler-config/chunkSplit.d.ts.map +0 -1
  62. package/dist-types/bundler-config/css.d.ts +0 -6
  63. package/dist-types/bundler-config/css.d.ts.map +0 -1
  64. package/dist-types/bundler-config/detectCircular.d.ts +0 -6
  65. package/dist-types/bundler-config/detectCircular.d.ts.map +0 -1
  66. package/dist-types/bundler-config/helpers.d.ts +0 -9
  67. package/dist-types/bundler-config/helpers.d.ts.map +0 -1
  68. package/dist-types/bundler-config/html.d.ts +0 -6
  69. package/dist-types/bundler-config/html.d.ts.map +0 -1
  70. package/dist-types/bundler-config/index.d.ts +0 -3
  71. package/dist-types/bundler-config/index.d.ts.map +0 -1
  72. package/dist-types/bundler-config/loaders/transformLoader.d.ts.map +0 -1
  73. package/dist-types/bundler-config/loaders/typedCssModulesLoader.d.ts.map +0 -1
  74. package/dist-types/bundler-config/nativeCss.d.ts +0 -6
  75. package/dist-types/bundler-config/nativeCss.d.ts.map +0 -1
  76. package/dist-types/bundler-config/plugins/jsMinify.d.ts.map +0 -1
  77. package/dist-types/bundler-config/plugins/progress/helpers.d.ts.map +0 -1
  78. package/dist-types/bundler-config/plugins/progress/index.d.ts.map +0 -1
  79. package/dist-types/bundler-config/plugins/registerHooks.d.ts.map +0 -1
  80. package/dist-types/bundler-config/typeCheck.d.ts +0 -6
  81. package/dist-types/bundler-config/typeCheck.d.ts.map +0 -1
  82. package/dist-types/spinner.d.ts +0 -9
  83. package/dist-types/spinner.d.ts.map +0 -1
  84. package/dist-types/types/chunkSplit.d.ts +0 -23
  85. package/dist-types/types/chunkSplit.d.ts.map +0 -1
  86. /package/dist-types/{bundler-config → rspack-config}/loaders/transformLoader.d.ts +0 -0
  87. /package/dist-types/{bundler-config → rspack-config}/loaders/typedCssModulesLoader.d.ts +0 -0
  88. /package/dist-types/{bundler-config → rspack-config}/plugins/jsMinify.d.ts +0 -0
  89. /package/dist-types/{bundler-config → rspack-config}/plugins/progress/helpers.d.ts +0 -0
  90. /package/dist-types/{bundler-config → rspack-config}/plugins/progress/index.d.ts +0 -0
package/dist/index.js CHANGED
@@ -20,7 +20,6 @@ import { parse } from "stacktrace-parser";
20
20
  import node_zlib from "node:zlib";
21
21
  import magic_string from "magic-string";
22
22
  import { expand } from "dotenv-expand";
23
- import node_assert from "node:assert";
24
23
  import { RspackDevServer } from "@rspack/dev-server";
25
24
  import { exec, spawn } from "node:child_process";
26
25
  import chokidar from "chokidar";
@@ -122,7 +121,7 @@ let CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]', CSS_MODULE
122
121
  </body>
123
122
  </html>`, JS_REGEX = /\.[jt]s$/, JSX_REGEX = /\.[jt]sx$/, SCRIPT_REGEX = /\.[jt]sx?$/;
124
123
  var utils_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
125
- let { merge: mergeConfig } = __webpack_require__("compiled/webpack-merge"), { default: launchEditor } = __webpack_require__("compiled/launch-editor"), getNodeEnv = ()=>process.env.NODE_ENV, setNodeEnv = (env)=>{
124
+ let { merge: utils_mergeConfig } = __webpack_require__("compiled/webpack-merge"), { default: launchEditor } = __webpack_require__("compiled/launch-editor"), getNodeEnv = ()=>process.env.NODE_ENV, setNodeEnv = (env)=>{
126
125
  process.env.NODE_ENV = env;
127
126
  }, setDevServer = (isDevServer)=>{
128
127
  process.env.DEV_SERVER = isDevServer ? 'true' : 'false';
@@ -638,7 +637,7 @@ let COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|
638
637
  'react-router-dom': 'ReactRouterDOM'
639
638
  };
640
639
  return externalAlias[pkgName] ? externalAlias[pkgName] : pkgName.replace(/^@/, '').split(/[/\-.]/).filter(Boolean).map((part)=>part.charAt(0).toUpperCase() + part.slice(1)).join('');
641
- }, getExternalValue = (pkgName)=>`window ${getExternalLibraryName(pkgName)}`, normalizeSvg = (content)=>content.replace(/<\?xml[\s\S]*?\?>/gi, '').replace(/<!DOCTYPE[\s\S]*?>/gi, '').replace(/<!--[\s\S]*?-->/g, '').trim(), extractSvgContent = (content)=>{
640
+ }, getExternalValue = (pkgName)=>`window ${getExternalLibraryName(pkgName)}`, MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, normalizeSvg = (content)=>content.replace(/<\?xml[\s\S]*?\?>/gi, '').replace(/<!DOCTYPE[\s\S]*?>/gi, '').replace(/<!--[\s\S]*?-->/g, '').trim(), extractSvgContent = (content)=>{
642
641
  let match = content.match(/<svg\b([^>]*)>/i), viewBoxMatch = match?.[1]?.match(/viewBox\s*=\s*["']([^"']+)["']/i);
643
642
  return {
644
643
  inner: content.replace(/^[\s\S]*?<svg\b[^>]*>/i, '').replace(/<\/svg>[\s\S]*$/i, '').trim(),
@@ -783,105 +782,17 @@ async function applyCacheConfig({ config, unpackConfig, envFilePaths }) {
783
782
  let cacheConfig = isPlainObject(unpackConfig.performance.cache) ? unpackConfig.performance.cache : {}, buildDependencies = await getBuildDependencies(unpackConfig.root);
784
783
  buildDependencies.userBuildDependencies = cacheConfig.buildDependencies || [], buildDependencies.envFilePaths = envFilePaths;
785
784
  let cacheDirectory = node_path.resolve(unpackConfig.root, cacheConfig.cacheDirectory || `${unpackConfig._context.cachePath}/cache`, utils_isDevServer() ? 'dev' : 'build');
786
- return mergeConfig(config, {
787
- cache: !0,
788
- experiments: {
789
- cache: {
790
- type: 'persistent',
791
- buildDependencies: Object.values(buildDependencies).flat(),
792
- storage: {
793
- type: 'filesystem',
794
- directory: cacheDirectory
795
- }
785
+ return utils_mergeConfig(config, {
786
+ cache: {
787
+ type: 'persistent',
788
+ buildDependencies: Object.values(buildDependencies).flat(),
789
+ storage: {
790
+ type: 'filesystem',
791
+ directory: cacheDirectory
796
792
  }
797
793
  }
798
794
  });
799
795
  }
800
- globalScope[TRANSFORM_TIMING_STORE] = transformTimingMap;
801
- let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, SPLIT_STRATEGY_DISPATCHER = {
802
- 'split-by-module': function(ctx) {
803
- let { forceSplittingGroups, defaultConfig } = ctx;
804
- return {
805
- ...defaultConfig,
806
- minSize: 0,
807
- maxInitialRequests: 1 / 0,
808
- cacheGroups: {
809
- ...defaultConfig.cacheGroups,
810
- ...forceSplittingGroups,
811
- vendors: {
812
- priority: -9,
813
- test: NODE_MODULES_REGEX,
814
- name: (module)=>module ? function(modulePath) {
815
- let handleModuleContext = modulePath?.match(MODULE_PATH_REGEX);
816
- if (!handleModuleContext) return;
817
- let [, scope, name] = handleModuleContext;
818
- return [
819
- 'npm',
820
- (scope ?? '').replace('@', ''),
821
- name
822
- ].filter(Boolean).join('.');
823
- }(module.context) : void 0
824
- }
825
- }
826
- };
827
- },
828
- 'split-by-size': function(ctx) {
829
- let { forceSplittingGroups, defaultConfig, chunkSplit } = ctx;
830
- return node_assert('split-by-size' === chunkSplit.strategy), {
831
- ...defaultConfig,
832
- minSize: chunkSplit.minSize ?? 50000,
833
- maxSize: chunkSplit.maxSize ?? 500000,
834
- cacheGroups: {
835
- ...defaultConfig.cacheGroups,
836
- ...forceSplittingGroups
837
- }
838
- };
839
- },
840
- custom: function(ctx) {
841
- let userSplitChunks, { forceSplittingGroups, defaultConfig, chunkSplit } = ctx;
842
- if ('splitChunks' in chunkSplit && (userSplitChunks = chunkSplit.splitChunks), void 0 === userSplitChunks) return {
843
- ...defaultConfig,
844
- cacheGroups: {
845
- ...defaultConfig.cacheGroups,
846
- ...forceSplittingGroups
847
- }
848
- };
849
- if (!1 === userSplitChunks) return Object.keys(forceSplittingGroups).length > 0 && {
850
- chunks: 'all',
851
- cacheGroups: {
852
- ...forceSplittingGroups
853
- }
854
- };
855
- let baseConfig = userSplitChunks;
856
- return {
857
- ...baseConfig,
858
- cacheGroups: {
859
- ...baseConfig.cacheGroups || {},
860
- ...forceSplittingGroups
861
- }
862
- };
863
- },
864
- 'all-in-one': function(_ctx) {
865
- return !1;
866
- },
867
- 'single-vendor': function(ctx) {
868
- let { defaultConfig, forceSplittingGroups } = ctx;
869
- return {
870
- ...defaultConfig,
871
- cacheGroups: {
872
- ...defaultConfig.cacheGroups,
873
- singleVendor: {
874
- test: NODE_MODULES_REGEX,
875
- priority: 0,
876
- chunks: 'all',
877
- name: 'vendor',
878
- enforce: !0
879
- },
880
- ...forceSplittingGroups
881
- }
882
- };
883
- }
884
- };
885
796
  async function getEntry(root, customEntry) {
886
797
  let entry;
887
798
  if (entry = customEntry ? node_path.resolve(root, customEntry) : (await external_tinyglobby_glob('(index|main).{js,ts,jsx,tsx}', {
@@ -890,10 +801,43 @@ async function getEntry(root, customEntry) {
890
801
  }))[0], !node_fs.existsSync(entry)) throw Error('could not find entry file');
891
802
  return entry;
892
803
  }
804
+ globalScope[TRANSFORM_TIMING_STORE] = transformTimingMap;
893
805
  let getOutputFilename = ({ type, hash, async })=>{
894
806
  let FILENAME = utils_isProd() && !1 !== hash ? PROD_DEFAULT_FILENAME : DEV_DEFAULT_FILENAME;
895
807
  return async ? 'js' === type ? FILENAME.jsAsync : FILENAME.cssAsync : FILENAME[type];
896
- };
808
+ }, getCssLoader = (unpackConfig)=>unpackConfig.css?.transformer === 'lightningcss' ? {
809
+ loader: 'builtin:lightningcss-loader',
810
+ options: {
811
+ targets: esVersionToBrowserslist(unpackConfig.build.target),
812
+ ...unpackConfig.css?.lightningcssLoader
813
+ }
814
+ } : {
815
+ loader: getCompiledPkgPath('postcss-loader'),
816
+ options: {
817
+ sourceMap: unpackConfig.css?.sourceMap,
818
+ ...unpackConfig.css?.postcssLoader
819
+ }
820
+ }, getSassLoader = (unpackConfig)=>({
821
+ loader: getCompiledPkgPath('sass-loader'),
822
+ options: {
823
+ api: 'modern-compiler',
824
+ implementation: getUserDepPath(unpackConfig.root, [
825
+ 'sass-embedded',
826
+ 'sass'
827
+ ]),
828
+ sourceMap: unpackConfig.css?.sourceMap,
829
+ ...unpackConfig.css?.sassLoader
830
+ }
831
+ }), getLessLoader = (unpackConfig)=>({
832
+ loader: getCompiledPkgPath('less-loader'),
833
+ options: utils_mergeConfig({
834
+ lessOptions: {
835
+ javascriptEnabled: !0
836
+ },
837
+ implementation: getUserDepPath(unpackConfig.root, 'less'),
838
+ sourceMap: unpackConfig.css?.sourceMap
839
+ }, unpackConfig.css?.lessLoader || {})
840
+ });
897
841
  var css_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
898
842
  async function applyHtmlConfig({ config, unpackConfig }) {
899
843
  let htmlConfig = unpackConfig.html || {}, { template, templateContent } = getHtmlTemplateOrContent(htmlConfig.template, unpackConfig.root), templateParameters = {
@@ -926,7 +870,7 @@ class JsMinifyPlugin {
926
870
  apply(compiler) {
927
871
  let meta = JSON.stringify({
928
872
  name: jsMinify_PLUGIN_NAME,
929
- version: "4.4.0",
873
+ version: "4.6.0",
930
874
  options: this.minifyOptions
931
875
  });
932
876
  compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
@@ -961,38 +905,11 @@ class JsMinifyPlugin {
961
905
  }));
962
906
  }
963
907
  }
964
- class Spinner {
965
- chars = [
966
- '⠋',
967
- '⠙',
968
- '⠹',
969
- '⠸',
970
- '⠼',
971
- '⠴',
972
- '⠦',
973
- '⠧',
974
- '⠇',
975
- '⠏'
976
- ];
977
- currentIndex = 0;
978
- lastUpdateTime = 0;
979
- interval = 100;
980
- getCurrentChar() {
981
- let now = Date.now();
982
- return now - this.lastUpdateTime >= this.interval && (this.currentIndex = (this.currentIndex + 1) % this.chars.length, this.lastUpdateTime = now), this.chars[this.currentIndex];
983
- }
984
- reset() {
985
- this.currentIndex = 0, this.lastUpdateTime = 0;
986
- }
987
- }
988
908
  class ProgressBar {
989
909
  prefix = 'transforming';
990
- spinner = new Spinner();
991
- update({ current: originalCurrent, message = '' }) {
992
- let { columns: terminalWidth } = process.stdout, current = originalCurrent;
993
- originalCurrent >= 0.98 && (current = 1);
994
- let loadingChar = this.spinner.getCurrentChar(), messageWidth = terminalWidth - this.prefix.length - (1 === current ? 10 : 9);
995
- logUpdate(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`), 1 === current && clearLine();
910
+ update({ percentage, message = '' }) {
911
+ let { columns: terminalWidth } = process.stdout, messageWidth = terminalWidth - this.prefix.length - (1 === percentage ? 10 : 9);
912
+ logUpdate(`${this.prefix} (${Math.floor(100 * percentage)}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`), 1 === percentage && clearLine();
996
913
  }
997
914
  }
998
915
  function isLikelyFile(filePath) {
@@ -1054,10 +971,10 @@ class ProgressLitePlugin {
1054
971
  class ProgressPlugin extends rspack.ProgressPlugin {
1055
972
  progressBar = new ProgressBar();
1056
973
  constructor(){
1057
- super((percentage, msg, ...args)=>{
974
+ super((percentage, message)=>{
1058
975
  utils_isProd() && this.progressBar.update({
1059
- current: percentage,
1060
- message: `${msg} ${args.join(' ')}`
976
+ percentage,
977
+ message
1061
978
  });
1062
979
  });
1063
980
  }
@@ -1070,7 +987,6 @@ class ProgressPlugin extends rspack.ProgressPlugin {
1070
987
  let registerHooks_PLUGIN_NAME = 'RegisterHooksPlugin';
1071
988
  class RegisterHooksPlugin {
1072
989
  isFirstCompile = !0;
1073
- lastVirtualModules = new Map();
1074
990
  lastLoadedModules = new Map();
1075
991
  resolveIdTimings = new Map();
1076
992
  loadTimings = new Map();
@@ -1116,15 +1032,9 @@ class RegisterHooksPlugin {
1116
1032
  let loaded = await load(id);
1117
1033
  null !== loaded && prev !== loaded && (this.lastLoadedModules.set(id, loaded), virtualModulesPlugin.writeModule(id, loaded));
1118
1034
  }
1119
- }, updateVirtualModules = ()=>{
1120
- applyPluginsByHookSync('virtualModules', (impl)=>{
1121
- Object.entries(impl()).forEach(([path, content])=>{
1122
- this.lastVirtualModules.get(path) !== content && (this.lastVirtualModules.set(path, content), virtualModulesPlugin.writeModule(path, content));
1123
- });
1124
- });
1125
1035
  };
1126
1036
  compiler.hooks.thisCompilation.tap(registerHooks_PLUGIN_NAME, (compilation)=>{
1127
- updateVirtualModules(), applyPluginsByHook('processAssets', (impl, plugin)=>{
1037
+ applyPluginsByHookSync('processAssets', (impl, plugin)=>{
1128
1038
  let { stage, handler } = impl;
1129
1039
  compilation.hooks.processAssets.tapPromise({
1130
1040
  name: registerHooks_PLUGIN_NAME,
@@ -1168,7 +1078,7 @@ class RegisterHooksPlugin {
1168
1078
  }), this.isFirstCompile = !1;
1169
1079
  }), compiler.hooks.afterDone.tap(registerHooks_PLUGIN_NAME, ()=>{
1170
1080
  this.isCompiling = !1, isDev() && (clearTimeout(this.idleTimer), this.idleTimer = setTimeout(()=>{
1171
- this.isCompiling || (updateVirtualModules(), updateLoadedModules());
1081
+ this.isCompiling || updateLoadedModules();
1172
1082
  }, 50));
1173
1083
  });
1174
1084
  }
@@ -1202,20 +1112,20 @@ async function applyTypeCheckConfig({ config, unpackConfig }) {
1202
1112
  }
1203
1113
  })), config;
1204
1114
  }
1205
- var bundler_config_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
1206
- async function getBundlerConfig(originalUnpackConfig) {
1115
+ var rspack_config_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
1116
+ async function getRspackConfig(originalUnpackConfig) {
1207
1117
  setCurrentUnpackConfig(originalUnpackConfig);
1208
- let { plugins, bundlerConfig, ...rest } = originalUnpackConfig;
1118
+ let { plugins, rspack: rspackConfig, ...rest } = originalUnpackConfig;
1209
1119
  await applyPluginsByHook('config', async (impl)=>{
1210
1120
  rest = await impl(rest, {
1211
1121
  ...originalUnpackConfig._context,
1212
- mergeConfig: mergeConfig
1122
+ mergeConfig: utils_mergeConfig
1213
1123
  });
1214
1124
  });
1215
1125
  let unpackConfig = {
1216
1126
  ...rest,
1217
1127
  plugins,
1218
- bundlerConfig
1128
+ rspack: rspackConfig
1219
1129
  };
1220
1130
  setCurrentUnpackConfig(unpackConfig), await applyPluginsByHook('configResolved', async (impl)=>{
1221
1131
  await impl(unpackConfig, originalUnpackConfig._context);
@@ -1313,9 +1223,14 @@ async function getBundlerConfig(originalUnpackConfig) {
1313
1223
  {
1314
1224
  test: /\.wasm$/,
1315
1225
  dependency: 'url',
1316
- type: 'asset/resource'
1226
+ type: 'webassembly/async'
1317
1227
  }
1318
- ]
1228
+ ],
1229
+ parser: {
1230
+ javascript: {
1231
+ exportsPresence: 'warn'
1232
+ }
1233
+ }
1319
1234
  },
1320
1235
  plugins: [
1321
1236
  new rspack.DefinePlugin({
@@ -1365,20 +1280,18 @@ async function getBundlerConfig(originalUnpackConfig) {
1365
1280
  entries: !!unpackConfig.mpa
1366
1281
  },
1367
1282
  experiments: {
1368
- css: !1,
1369
- asyncWebAssembly: !0,
1370
1283
  nativeWatcher: !0
1371
1284
  },
1372
1285
  optimization: {
1373
1286
  moduleIds: isDev() ? 'named' : 'deterministic',
1374
1287
  minimize: !!unpackConfig.build?.minify && utils_isProd(),
1375
1288
  minimizer: [
1376
- new JsMinifyPlugin(mergeConfig({
1289
+ new JsMinifyPlugin(utils_mergeConfig({
1377
1290
  compress: {
1378
1291
  target: unpackConfig.build.target
1379
1292
  }
1380
1293
  }, minifyOptions.oxc || {})),
1381
- new rspack.LightningCssMinimizerRspackPlugin(mergeConfig({
1294
+ new rspack.LightningCssMinimizerRspackPlugin(utils_mergeConfig({
1382
1295
  minimizerOptions: {
1383
1296
  targets: esVersionToBrowserslist(unpackConfig.build.target)
1384
1297
  }
@@ -1400,7 +1313,7 @@ async function getBundlerConfig(originalUnpackConfig) {
1400
1313
  enforce: 'pre',
1401
1314
  use: [
1402
1315
  {
1403
- loader: node_path.resolve(bundler_config_dirname, './transformLoader.js'),
1316
+ loader: node_path.resolve(rspack_config_dirname, './transformLoader.js'),
1404
1317
  options: {
1405
1318
  handler,
1406
1319
  pluginName: plugin.name
@@ -1408,261 +1321,137 @@ async function getBundlerConfig(originalUnpackConfig) {
1408
1321
  }
1409
1322
  ]
1410
1323
  });
1411
- }), config = (({ config, unpackConfig })=>{
1412
- let { chunkSplit } = unpackConfig.performance || {};
1413
- if (chunkSplit?.strategy) {
1414
- let forceSplittingGroups = {};
1415
- chunkSplit?.forceSplitting && (forceSplittingGroups = function(forceSplitting, strategy) {
1416
- let cacheGroups = {};
1417
- for (let [key, regexp] of Array.isArray(forceSplitting) ? forceSplitting.map((regexp, index)=>[
1418
- `force-split-${index}`,
1419
- regexp
1420
- ]) : Object.entries(forceSplitting))cacheGroups[key] = {
1421
- test: regexp,
1422
- name: key,
1423
- chunks: 'all',
1424
- priority: +('single-vendor' === strategy),
1425
- enforce: !0
1426
- };
1427
- return cacheGroups;
1428
- }(chunkSplit.forceSplitting, chunkSplit.strategy)), set(config, [
1429
- 'optimization',
1430
- 'splitChunks'
1431
- ], SPLIT_STRATEGY_DISPATCHER[chunkSplit.strategy]({
1432
- defaultConfig: {
1433
- chunks: 'all'
1434
- },
1435
- forceSplittingGroups,
1436
- chunkSplit
1437
- }));
1438
- }
1439
- return config;
1440
- })({
1441
- config: config = unpackConfig.css?.native ? function({ config, unpackConfig }) {
1442
- config.output.cssFilename = getOutputFilename({
1443
- type: 'css',
1444
- hash: unpackConfig.build?.filenameHash
1445
- }), config.output.cssChunkFilename = getOutputFilename({
1446
- type: 'css',
1447
- hash: unpackConfig.build?.filenameHash,
1448
- async: !0
1449
- }), set(config, [
1450
- 'experiments',
1451
- 'css'
1452
- ], !0);
1453
- let sourceMap = unpackConfig.css?.sourceMap;
1454
- set(config, [
1455
- 'module',
1456
- 'parser',
1457
- 'css/module'
1458
- ], {
1459
- namedExports: !1
1460
- }), set(config, [
1461
- 'module',
1462
- 'generator',
1463
- 'css/module'
1464
- ], {
1465
- localIdentName: CSS_MODULES_LOCAL_IDENT_NAME,
1466
- exportsConvention: CSS_MODULES_EXPORTS_CONVENTION
1467
- });
1468
- let withCssModules = ({ use })=>({
1469
- resourceQuery: /[?&]module(?:[=&]|$)/,
1470
- use: [
1471
- isDev() && {
1472
- loader: node_path.resolve(nativeCss_dirname, './typedCssModulesLoader.js')
1473
- },
1474
- ...use
1475
- ].filter(Boolean),
1476
- type: 'css/module'
1477
- }), getLessLoader = ()=>({
1478
- loader: getCompiledPkgPath('less-loader'),
1479
- options: mergeConfig({
1480
- lessOptions: {
1481
- javascriptEnabled: !0
1482
- },
1483
- implementation: getUserDepPath(unpackConfig.root, 'less'),
1484
- sourceMap
1485
- }, unpackConfig.css?.lessLoader || {})
1486
- }), getCssLoader = ()=>unpackConfig.css?.transformer === 'lightningcss' ? {
1487
- loader: 'builtin:lightningcss-loader',
1488
- options: {
1489
- targets: esVersionToBrowserslist(unpackConfig.build.target),
1490
- ...unpackConfig.css?.lightningcssLoader
1491
- }
1492
- } : {
1493
- loader: getCompiledPkgPath('postcss-loader'),
1494
- options: {
1495
- sourceMap,
1496
- ...unpackConfig.css?.postcssLoader
1497
- }
1498
- }, getSassLoader = ()=>({
1499
- loader: getCompiledPkgPath('sass-loader'),
1500
- options: {
1501
- api: 'modern-compiler',
1502
- implementation: getUserDepPath(unpackConfig.root, [
1503
- 'sass-embedded',
1504
- 'sass'
1505
- ]),
1506
- sourceMap,
1507
- ...unpackConfig.css?.sassLoader
1508
- }
1509
- });
1510
- return config.module.rules.push({
1511
- test: /\.css$/i,
1512
- oneOf: [
1513
- withCssModules({
1514
- use: [
1515
- getCssLoader()
1516
- ]
1517
- }),
1518
- {
1519
- use: [
1520
- getCssLoader()
1521
- ],
1522
- type: 'css'
1523
- }
1524
- ].filter(Boolean)
1525
- }), config.module.rules.push({
1526
- test: /\.less$/i,
1527
- oneOf: [
1528
- withCssModules({
1529
- use: [
1530
- getCssLoader(),
1531
- getLessLoader()
1532
- ]
1533
- }),
1534
- {
1535
- use: [
1536
- getCssLoader(),
1537
- getLessLoader()
1538
- ],
1539
- type: 'css'
1540
- }
1541
- ].filter(Boolean)
1542
- }), config.module.rules.push({
1543
- test: /\.s[ac]ss$/i,
1324
+ }), config = unpackConfig.css?.native ? function({ config, unpackConfig }) {
1325
+ config.output.cssFilename = getOutputFilename({
1326
+ type: 'css',
1327
+ hash: unpackConfig.build?.filenameHash
1328
+ }), config.output.cssChunkFilename = getOutputFilename({
1329
+ type: 'css',
1330
+ hash: unpackConfig.build?.filenameHash,
1331
+ async: !0
1332
+ }), set(config, [
1333
+ 'module',
1334
+ 'parser',
1335
+ 'css/module'
1336
+ ], {
1337
+ namedExports: !1
1338
+ }), set(config, [
1339
+ 'module',
1340
+ 'generator',
1341
+ 'css/module'
1342
+ ], {
1343
+ localIdentName: CSS_MODULES_LOCAL_IDENT_NAME,
1344
+ exportsConvention: CSS_MODULES_EXPORTS_CONVENTION
1345
+ });
1346
+ let createStyleRule = (test, items)=>{
1347
+ let use = items.filter(Boolean);
1348
+ return {
1349
+ test,
1544
1350
  oneOf: [
1545
- withCssModules({
1546
- use: [
1547
- getCssLoader(),
1548
- getSassLoader()
1549
- ]
1351
+ (({ use })=>({
1352
+ resourceQuery: /[?&]module(?:[=&]|$)/,
1353
+ use: [
1354
+ isDev() && {
1355
+ loader: node_path.resolve(nativeCss_dirname, './typedCssModulesLoader.js')
1356
+ },
1357
+ ...use
1358
+ ].filter(Boolean),
1359
+ type: 'css/module'
1360
+ }))({
1361
+ use
1550
1362
  }),
1551
1363
  {
1552
- use: [
1553
- getCssLoader(),
1554
- getSassLoader()
1555
- ],
1364
+ use,
1556
1365
  type: 'css'
1557
1366
  }
1558
- ].filter(Boolean)
1559
- }), config;
1560
- }({
1561
- config,
1562
- unpackConfig
1563
- }) : function({ config, unpackConfig }) {
1564
- let sourceMap = unpackConfig.css?.sourceMap, getCommonRules = ({ importLoaders })=>[
1565
- utils_isDevServer() ? {
1566
- loader: getCompiledPkgPath('style-loader')
1567
- } : {
1568
- loader: rspack.CssExtractRspackPlugin.loader,
1569
- options: {
1570
- defaultExport: !0
1571
- }
1572
- },
1573
- isDev() && {
1574
- loader: node_path.resolve(css_dirname, './typedCssModulesLoader.js')
1575
- },
1576
- {
1577
- loader: getCompiledPkgPath('css-loader'),
1578
- options: {
1579
- importLoaders,
1580
- modules: {
1581
- auto: (_, resourceQuery)=>resourceQuery?.includes('module'),
1582
- localIdentName: CSS_MODULES_LOCAL_IDENT_NAME,
1583
- exportLocalsConvention: CSS_MODULES_EXPORTS_CONVENTION,
1584
- namedExport: !1
1585
- },
1586
- sourceMap
1587
- }
1588
- }
1589
- ].filter(Boolean);
1590
- utils_isDevServer() || config.plugins.push(new rspack.CssExtractRspackPlugin({
1591
- filename: getOutputFilename({
1592
- type: 'css',
1593
- hash: unpackConfig.build?.filenameHash
1594
- }),
1595
- chunkFilename: getOutputFilename({
1596
- type: 'css',
1597
- hash: unpackConfig.build?.filenameHash,
1598
- async: !0
1599
- }),
1600
- ignoreOrder: !0
1601
- }));
1602
- let getCssLoader = ()=>unpackConfig.css?.transformer === 'lightningcss' ? {
1603
- loader: 'builtin:lightningcss-loader',
1604
- options: {
1605
- targets: esVersionToBrowserslist(unpackConfig.build.target),
1606
- ...unpackConfig.css?.lightningcssLoader
1607
- }
1367
+ ]
1368
+ };
1369
+ };
1370
+ return config.module.rules.push(createStyleRule(/\.css$/i, [
1371
+ getCssLoader(unpackConfig),
1372
+ unpackConfig.css?.tailwindcss && {
1373
+ loader: require.resolve('@tailwindcss/webpack')
1374
+ }
1375
+ ])), config.module.rules.push(createStyleRule(/\.less$/i, [
1376
+ getCssLoader(unpackConfig),
1377
+ getLessLoader(unpackConfig)
1378
+ ])), config.module.rules.push(createStyleRule(/\.s[ac]ss$/i, [
1379
+ getCssLoader(unpackConfig),
1380
+ getSassLoader(unpackConfig)
1381
+ ])), config;
1382
+ }({
1383
+ config,
1384
+ unpackConfig
1385
+ }) : function({ config, unpackConfig }) {
1386
+ let getCommonRules = ({ importLoaders })=>[
1387
+ utils_isDevServer() ? {
1388
+ loader: getCompiledPkgPath('style-loader')
1608
1389
  } : {
1609
- loader: getCompiledPkgPath('postcss-loader'),
1390
+ loader: rspack.CssExtractRspackPlugin.loader,
1610
1391
  options: {
1611
- sourceMap,
1612
- ...unpackConfig.css?.postcssLoader
1613
- }
1614
- };
1615
- return config.module.rules.push({
1616
- test: /\.less$/i,
1617
- use: [
1618
- ...getCommonRules({
1619
- importLoaders: 2
1620
- }),
1621
- getCssLoader(),
1622
- {
1623
- loader: getCompiledPkgPath('less-loader'),
1624
- options: mergeConfig({
1625
- lessOptions: {
1626
- javascriptEnabled: !0
1627
- },
1628
- implementation: getUserDepPath(unpackConfig.root, 'less'),
1629
- sourceMap
1630
- }, unpackConfig.css?.lessLoader || {})
1392
+ defaultExport: !0
1631
1393
  }
1632
- ]
1633
- }), config.module.rules.push({
1634
- test: /\.css$/i,
1635
- use: [
1636
- ...getCommonRules({
1637
- importLoaders: 1
1638
- }),
1639
- getCssLoader()
1640
- ]
1641
- }), config.module.rules.push({
1642
- test: /\.s[ac]ss$/i,
1643
- use: [
1644
- ...getCommonRules({
1645
- importLoaders: 2
1646
- }),
1647
- getCssLoader(),
1648
- {
1649
- loader: getCompiledPkgPath('sass-loader'),
1650
- options: {
1651
- api: 'modern-compiler',
1652
- implementation: getUserDepPath(unpackConfig.root, [
1653
- 'sass-embedded',
1654
- 'sass'
1655
- ]),
1656
- sourceMap,
1657
- ...unpackConfig.css?.sassLoader
1658
- }
1394
+ },
1395
+ isDev() && {
1396
+ loader: node_path.resolve(css_dirname, './typedCssModulesLoader.js')
1397
+ },
1398
+ {
1399
+ loader: getCompiledPkgPath('css-loader'),
1400
+ options: {
1401
+ importLoaders,
1402
+ modules: {
1403
+ auto: (_, resourceQuery)=>resourceQuery?.includes('module'),
1404
+ localIdentName: CSS_MODULES_LOCAL_IDENT_NAME,
1405
+ exportLocalsConvention: CSS_MODULES_EXPORTS_CONVENTION,
1406
+ namedExport: !1
1407
+ },
1408
+ sourceMap: unpackConfig.css?.sourceMap
1659
1409
  }
1660
- ]
1661
- }), config;
1662
- }({
1663
- config,
1664
- unpackConfig
1665
- }),
1410
+ }
1411
+ ].filter(Boolean);
1412
+ return utils_isDevServer() || config.plugins.push(new rspack.CssExtractRspackPlugin({
1413
+ filename: getOutputFilename({
1414
+ type: 'css',
1415
+ hash: unpackConfig.build?.filenameHash
1416
+ }),
1417
+ chunkFilename: getOutputFilename({
1418
+ type: 'css',
1419
+ hash: unpackConfig.build?.filenameHash,
1420
+ async: !0
1421
+ }),
1422
+ ignoreOrder: !0
1423
+ })), config.module.rules.push({
1424
+ test: /\.less$/i,
1425
+ use: [
1426
+ ...getCommonRules({
1427
+ importLoaders: 2
1428
+ }),
1429
+ getCssLoader(unpackConfig),
1430
+ getLessLoader(unpackConfig)
1431
+ ]
1432
+ }), config.module.rules.push({
1433
+ test: /\.css$/i,
1434
+ use: [
1435
+ ...getCommonRules({
1436
+ importLoaders: unpackConfig.css?.tailwindcss ? 2 : 1
1437
+ }),
1438
+ getCssLoader(unpackConfig),
1439
+ unpackConfig.css?.tailwindcss && {
1440
+ loader: require.resolve('@tailwindcss/webpack')
1441
+ }
1442
+ ].filter(Boolean)
1443
+ }), config.module.rules.push({
1444
+ test: /\.s[ac]ss$/i,
1445
+ use: [
1446
+ ...getCommonRules({
1447
+ importLoaders: 2
1448
+ }),
1449
+ getCssLoader(unpackConfig),
1450
+ getSassLoader(unpackConfig)
1451
+ ]
1452
+ }), config;
1453
+ }({
1454
+ config,
1666
1455
  unpackConfig
1667
1456
  }), unpackConfig.mpa || (config = await applyHtmlConfig({
1668
1457
  config,
@@ -1710,18 +1499,18 @@ async function getBundlerConfig(originalUnpackConfig) {
1710
1499
  }({
1711
1500
  config,
1712
1501
  unpackConfig
1713
- })), await applyPluginsByHook('bundlerConfig', async (impl)=>{
1502
+ })), await applyPluginsByHook('rspackConfig', async (impl)=>{
1714
1503
  config = await impl(config, {
1715
1504
  ...originalUnpackConfig._context,
1716
1505
  unpackConfig,
1717
- mergeConfig: mergeConfig
1506
+ mergeConfig: utils_mergeConfig
1718
1507
  });
1719
- }), unpackConfig.bundlerConfig && (config = isFunction(unpackConfig.bundlerConfig) ? await unpackConfig.bundlerConfig(config, {
1720
- mergeConfig: mergeConfig
1721
- }) : mergeConfig(config, unpackConfig.bundlerConfig)), config;
1508
+ }), unpackConfig.rspack && (config = isFunction(unpackConfig.rspack) ? await unpackConfig.rspack(config, {
1509
+ mergeConfig: utils_mergeConfig
1510
+ }) : utils_mergeConfig(config, unpackConfig.rspack)), config;
1722
1511
  }
1723
1512
  async function unpackBuild(unpackConfig) {
1724
- let compiler = rspack(await getBundlerConfig(unpackConfig)), handler = (err, stats)=>{
1513
+ let compiler = rspack(await getRspackConfig(unpackConfig)), handler = (err, stats)=>{
1725
1514
  if (err) {
1726
1515
  console.error(err.stack || err), err.details && console.error(err.details);
1727
1516
  return;
@@ -1797,7 +1586,7 @@ function execAsync(command, options) {
1797
1586
  });
1798
1587
  }
1799
1588
  async function unpackDev(unpackConfig) {
1800
- let compiler = rspack(await getBundlerConfig(unpackConfig)), port = await getPort(unpackConfig.server?.port), proxyConfig = unpackConfig.server?.proxy;
1589
+ let compiler = rspack(await getRspackConfig(unpackConfig)), port = await getPort(unpackConfig.server?.port), proxyConfig = unpackConfig.server?.proxy;
1801
1590
  isPlainObject(proxyConfig) && (proxyConfig = Object.entries(proxyConfig).map(([contextStr, target])=>{
1802
1591
  let baseConfig = {
1803
1592
  context: contextStr.split(','),
@@ -1839,7 +1628,7 @@ async function unpackDev(unpackConfig) {
1839
1628
  ...middlewares
1840
1629
  ]);
1841
1630
  let server = new RspackDevServer(devServerOptions, compiler);
1842
- await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v4.4.0`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - getUnpackStartTime()))} ${colors.dim('ms')}\n`), printServerUrls({
1631
+ await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v4.6.0`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - getUnpackStartTime()))} ${colors.dim('ms')}\n`), printServerUrls({
1843
1632
  port,
1844
1633
  host: unpackConfig.server.host,
1845
1634
  base: unpackConfig.base
@@ -1853,13 +1642,16 @@ async function unpackDev(unpackConfig) {
1853
1642
  function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'unpack' }) {
1854
1643
  let _context = {
1855
1644
  callerName,
1856
- version: "4.4.0",
1645
+ version: "4.6.0",
1857
1646
  cachePath: 'node_modules/.unpack'
1858
1647
  }, resolveConfig = (mode)=>{
1859
1648
  let rootPath, outputPath, basePath, cachedTraceMap, fs, isValidMethodName, parseFrame, formatOriginalLocation, formatFullStack, resolveErrorLocationAndStack, root, alias, shouldTransformDeepImport, preJsAssets, jsAssets, cssAssets, bundledDepsCachePath, deepImportPkgPattern, deepImportRegex, plugin, root1, uno, generated, configOrPathFromUnpackConfig, defaultsFromUnpackConfig, VIRTUAL_UNO_CSS_ID, rootDir, isMpa, unoConfig, configFilePath, unpackConfigPath, tokens, requestedLayers, tasks, unocssCacheDir, tokensCachePath, layersCachePath, timeCachePath, configHashCachePath, generatedCachePath, bundlerCacheDir, cachedTokensSize, cachedLayersSize, isCompiling, resolveUnocssConfig, flushTasks, getVirtualModuleContent, hash, restoreSkipCode, applyUnoTransformers, optionsFromUnpackConfig, rootPath1, registerCode, namesCode, defaultConfig = {
1860
1649
  root: cwd,
1861
1650
  base: '/',
1862
1651
  sourceMap: 'production' !== mode && 'cheap-module-source-map',
1652
+ splitChunks: {
1653
+ preset: 'single-vendor'
1654
+ },
1863
1655
  build: {
1864
1656
  outDir: 'dist',
1865
1657
  minify: !0,
@@ -1874,13 +1666,10 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
1874
1666
  mountId: 'root'
1875
1667
  },
1876
1668
  css: {
1877
- transformer: 'postcss',
1669
+ transformer: 'lightningcss',
1878
1670
  sourceMap: !1
1879
1671
  },
1880
1672
  performance: {
1881
- chunkSplit: {
1882
- strategy: 'single-vendor'
1883
- },
1884
1673
  printFileSize: !0
1885
1674
  },
1886
1675
  typeCheck: !0,
@@ -2434,9 +2223,6 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2434
2223
  optimization: {
2435
2224
  splitChunks: !1
2436
2225
  },
2437
- experiments: {
2438
- css: !0
2439
- },
2440
2226
  externals: depExternals
2441
2227
  });
2442
2228
  compiler.run((_, stats)=>{
@@ -2518,7 +2304,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2518
2304
  },
2519
2305
  ...middlewares
2520
2306
  ],
2521
- bundlerConfig: (config)=>{
2307
+ rspackConfig: (config)=>{
2522
2308
  let PLUGIN_NAME = 'InjectAssetsPlugin';
2523
2309
  return config.plugins.push({
2524
2310
  apply: (compiler)=>{
@@ -2614,7 +2400,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2614
2400
  let configFile = node_path.join(root, file);
2615
2401
  if (node_fs.existsSync(configFile)) return configFile;
2616
2402
  }
2617
- })(rootDir, configFilePath), configFromOption = mergeConfig(configFromOption, await loadConfigFromFile(configFilePath)), resolvedDefaults && (configFromOption = mergeConfig(resolvedDefaults, configFromOption)), configFromOption;
2403
+ })(rootDir, configFilePath), configFromOption = utils_mergeConfig(configFromOption, await loadConfigFromFile(configFilePath)), resolvedDefaults && (configFromOption = utils_mergeConfig(resolvedDefaults, configFromOption)), configFromOption;
2618
2404
  }, flushTasks = async ()=>{
2619
2405
  if (!tasks.length) return;
2620
2406
  logger_logger.debug(colors.yellow(`[unocss] Extract token from ${tasks.length} modules.`));
@@ -2780,11 +2566,67 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2780
2566
  },
2781
2567
  resolveId: (id)=>id.startsWith('virtual:svg-icons-') ? '\0' + id : null,
2782
2568
  load: (id)=>'\0virtual:svg-icons-register' === id ? registerCode || 'export default null' : '\0virtual:svg-icons-names' === id ? namesCode || 'export default []' : null
2783
- })
2569
+ }),
2570
+ {
2571
+ name: 'unpack:split-chunks',
2572
+ rspackConfig (config, { unpackConfig, mergeConfig }) {
2573
+ if (!1 === unpackConfig.splitChunks) return mergeConfig(config, {
2574
+ optimization: {
2575
+ splitChunks: !1
2576
+ }
2577
+ });
2578
+ let { preset = 'none', ...rest } = unpackConfig.splitChunks;
2579
+ return mergeConfig(config, {
2580
+ optimization: {
2581
+ splitChunks: {
2582
+ ...function(preset) {
2583
+ if (!preset) return {};
2584
+ switch(preset){
2585
+ case 'single-vendor':
2586
+ return {
2587
+ cacheGroups: {
2588
+ singleVendor: {
2589
+ test: NODE_MODULES_REGEX,
2590
+ priority: 0,
2591
+ chunks: 'all',
2592
+ name: 'vendor',
2593
+ enforce: !0
2594
+ }
2595
+ }
2596
+ };
2597
+ case 'per-package':
2598
+ return {
2599
+ minSize: 0,
2600
+ maxInitialRequests: 1 / 0,
2601
+ cacheGroups: {
2602
+ vendors: {
2603
+ priority: -9,
2604
+ test: NODE_MODULES_REGEX,
2605
+ name: (module)=>module ? function(modulePath) {
2606
+ let handleModuleContext = modulePath?.match(MODULE_PATH_REGEX);
2607
+ if (!handleModuleContext) return;
2608
+ let [, scope, name] = handleModuleContext;
2609
+ return `npm-${scope ? `${scope.replace('@', '')}_` : ''}${name}`;
2610
+ }(module.context) : void 0
2611
+ }
2612
+ }
2613
+ };
2614
+ case 'none':
2615
+ return {};
2616
+ default:
2617
+ throw Error(`Unknown splitChunks preset: ${preset}`);
2618
+ }
2619
+ }(preset),
2620
+ ...rest
2621
+ }
2622
+ }
2623
+ });
2624
+ }
2625
+ }
2784
2626
  ]
2785
2627
  };
2786
2628
  return {
2787
- ...mergeConfig(defaultConfig, userConfig),
2629
+ ...utils_mergeConfig(defaultConfig, userConfig),
2788
2630
  _context
2789
2631
  };
2790
2632
  };
@@ -2793,7 +2635,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2793
2635
  let mode = watch ? 'development' : 'production';
2794
2636
  setNodeEnv(mode);
2795
2637
  let config = resolveConfig(mode);
2796
- console.log(colors.brand(`${callerName} v4.4.0`), colors.cyan(`building for ${mode}...`)), await unpackBuild(config);
2638
+ console.log(colors.brand(`${callerName} v4.6.0`), colors.cyan(`building for ${mode}...`)), await unpackBuild(config);
2797
2639
  },
2798
2640
  dev: async ()=>{
2799
2641
  setUnpackStartTime(performance.now());
@@ -2824,8 +2666,10 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
2824
2666
  var injectFramework_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
2825
2667
  async function injectFrameworkPluginForDebug(userConfig) {
2826
2668
  var plugin;
2827
- let raw, framework, framework1 = (raw = process.env.FRAMEWORK, (framework = raw?.trim().toLowerCase()) ? 'react' === framework || 'vue' === framework ? framework : (logger_logger.warn(`Unknown FRAMEWORK "${raw}", fallback to "react".`), 'react') : 'react'), pluginPath = node_path.resolve(injectFramework_dirname, `../../plugin-${framework1}/dist/index.js`);
2828
- node_fs.existsSync(pluginPath) && (plugin = (0, (await import(pluginPath))[`plugin${framework1.charAt(0).toUpperCase() + framework1.slice(1)}`])(), userConfig.plugins ? userConfig.plugins.unshift(plugin) : userConfig.plugins = [
2669
+ let framework = process.env.FRAMEWORK?.trim();
2670
+ if (!framework) return;
2671
+ let pluginPath = node_path.resolve(injectFramework_dirname, `../../plugin-${framework}/dist/index.js`);
2672
+ node_fs.existsSync(pluginPath) && (plugin = (0, (await import(pluginPath))[`plugin${framework.charAt(0).toUpperCase() + framework.slice(1)}`])(), userConfig.plugins ? userConfig.plugins.unshift(plugin) : userConfig.plugins = [
2829
2673
  plugin
2830
2674
  ]);
2831
2675
  }
@@ -2942,7 +2786,7 @@ function runCLI() {
2942
2786
  logger_logger.clear(), logger_logger.info(`${node_path.basename(file)} changed, restarting server...`), await watcher.close(), await cleanUpBeforeRestart(), startServer(options);
2943
2787
  });
2944
2788
  });
2945
- devCommand.option('-o, --open [url]', 'Open browser on startup').option('--port <port>', 'Specify port').option('--host', 'Expose hostname').action(startServer), cli.help(), cli.version("4.4.0"), cli.parse();
2789
+ devCommand.option('-o, --open [url]', 'Open browser on startup').option('--port <port>', 'Specify port').option('--host', 'Expose hostname').action(startServer), cli.help(), cli.version("4.6.0"), cli.parse();
2946
2790
  }
2947
2791
  var src_CSS_MODULES_NAMED_EXPORT = !1;
2948
- export { ALL_INTERFACES_IPV4, CSS_MODULES_EXPORTS_CONVENTION, CSS_MODULES_LOCAL_IDENT_NAME, DEV_DEFAULT_FILENAME, JSX_REGEX, JS_REGEX, LOCALHOST, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, SCRIPT_REGEX, TEMPLATE_CONTENT, addRestartCleaner, applyHtmlTagDescriptors, cleanUpBeforeRestart, clearLine, colors, convertBasicAnsiColors, createChokidar, createUnpack, debounce, defineConfig, emptyDir, ensureDir, esVersionToBrowserslist, external_tinyglobby_glob as glob, findExists, getAddressUrls, getCompiledPkgPath, getCurrentUnpackConfig, getFilesContentHash, getHtmlTemplateOrContent, getIpv4Interfaces, getNodeEnv, getOrSetDefault, getPathInJs, getPort, getTime, getUnpackStartTime, getUserDepPath, getUserDepVersion, globSync, isBoolean, isDebug, isDev, isEmptyDir, isFileExists, isFileSync, isFunction, isNodeVersionAtLeast, isObject, isPlainObject, isRegExp, isString, isUndefined, isWin, launchEditor, loadConfig, loadConfigFromFile, logUpdate, logger_LogColor as LogColor, logger_logger as logger, mergeConfig, normalizePublicPath, openBrowser, pLimit, pathExists, pathToExportIdentifier, prettyTime, printServerUrls, removeDir, renderHtmlTagDescriptor, resolveConfigPath, rspack, runCLI, set, setCurrentUnpackConfig, setDevServer, setNodeEnv, setUnpackStartTime, src_CSS_MODULES_NAMED_EXPORT as CSS_MODULES_NAMED_EXPORT, trackPerformance, utils_isDevServer as isDevServer, utils_isProd as isProd };
2792
+ export { ALL_INTERFACES_IPV4, CSS_MODULES_EXPORTS_CONVENTION, CSS_MODULES_LOCAL_IDENT_NAME, DEV_DEFAULT_FILENAME, JSX_REGEX, JS_REGEX, LOCALHOST, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, SCRIPT_REGEX, TEMPLATE_CONTENT, addRestartCleaner, applyHtmlTagDescriptors, cleanUpBeforeRestart, clearLine, colors, convertBasicAnsiColors, createChokidar, createUnpack, debounce, defineConfig, emptyDir, ensureDir, esVersionToBrowserslist, external_tinyglobby_glob as glob, findExists, getAddressUrls, getCompiledPkgPath, getCurrentUnpackConfig, getFilesContentHash, getHtmlTemplateOrContent, getIpv4Interfaces, getNodeEnv, getOrSetDefault, getPathInJs, getPort, getTime, getUnpackStartTime, getUserDepPath, getUserDepVersion, globSync, isBoolean, isDebug, isDev, isEmptyDir, isFileExists, isFileSync, isFunction, isNodeVersionAtLeast, isObject, isPlainObject, isRegExp, isString, isUndefined, isWin, launchEditor, loadConfig, loadConfigFromFile, logUpdate, logger_LogColor as LogColor, logger_logger as logger, normalizePublicPath, openBrowser, pLimit, pathExists, pathToExportIdentifier, prettyTime, printServerUrls, removeDir, renderHtmlTagDescriptor, resolveConfigPath, rspack, runCLI, set, setCurrentUnpackConfig, setDevServer, setNodeEnv, setUnpackStartTime, src_CSS_MODULES_NAMED_EXPORT as CSS_MODULES_NAMED_EXPORT, trackPerformance, utils_isDevServer as isDevServer, utils_isProd as isProd, utils_mergeConfig as mergeConfig };