@unpackjs/core 4.3.0 → 4.5.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 (32) 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 +160 -211
  10. package/dist-types/bundler-config/cache.d.ts.map +1 -1
  11. package/dist-types/bundler-config/css.d.ts.map +1 -1
  12. package/dist-types/bundler-config/helpers.d.ts +45 -0
  13. package/dist-types/bundler-config/helpers.d.ts.map +1 -1
  14. package/dist-types/bundler-config/index.d.ts.map +1 -1
  15. package/dist-types/bundler-config/nativeCss.d.ts.map +1 -1
  16. package/dist-types/bundler-config/plugins/progress/index.d.ts.map +1 -1
  17. package/dist-types/bundler-config/plugins/registerHooks.d.ts +3 -1
  18. package/dist-types/bundler-config/plugins/registerHooks.d.ts.map +1 -1
  19. package/dist-types/cli/injectFramework.d.ts +1 -1
  20. package/dist-types/cli/injectFramework.d.ts.map +1 -1
  21. package/dist-types/plugins/prebundle.d.ts.map +1 -1
  22. package/dist-types/plugins/svgIcons.d.ts.map +1 -1
  23. package/dist-types/plugins/unocss.d.ts.map +1 -1
  24. package/dist-types/progressBar.d.ts +2 -2
  25. package/dist-types/progressBar.d.ts.map +1 -1
  26. package/dist-types/types/config.d.ts +2 -10
  27. package/dist-types/types/config.d.ts.map +1 -1
  28. package/dist-types/types/plugin.d.ts +4 -1
  29. package/dist-types/types/plugin.d.ts.map +1 -1
  30. package/dist-types/utils.d.ts +1 -1
  31. package/dist-types/utils.d.ts.map +1 -1
  32. package/package.json +8 -7
package/dist/index.js CHANGED
@@ -383,7 +383,7 @@ let VOID_TAGS = new Set([
383
383
  for (let tag of tags || [])buckets[tag.injectTo || 'head-prepend'].push(renderHtmlTagDescriptor(tag));
384
384
  let result = html;
385
385
  return result = injectHtml(result, 'head-prepend', buckets['head-prepend'].join('')), result = injectHtml(result, 'head', buckets.head.join('')), result = injectHtml(result, 'body-prepend', buckets['body-prepend'].join('')), result = injectHtml(result, 'body', buckets.body.join(''));
386
- }, loadConfigFile = async (configFilePath)=>{
386
+ }, loadConfigFromFile = async (configFilePath)=>{
387
387
  if (isNodeVersionAtLeast(22, 18) || /\.(?:js|mjs|cjs)$/.test(configFilePath)) {
388
388
  logger_logger.debug('loading config file with native loader:', colors.dim(configFilePath));
389
389
  let configFileURL = pathToFileURL(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
@@ -445,7 +445,7 @@ let VOID_TAGS = new Set([
445
445
  async function loadConfig({ cliOptions, command }) {
446
446
  'build' === command ? setNodeEnv(cliOptions?.watch ? 'development' : 'production') : (setNodeEnv('development'), setDevServer(!0));
447
447
  let root = cliOptions?.root ? node_path.resolve(cliOptions.root) : process.cwd(), configFilePath = resolveConfigPath(root, cliOptions?.config), configExport = {};
448
- if (configFilePath && 'function' == typeof (configExport = await loadConfigFile(configFilePath))) {
448
+ if (configFilePath && 'function' == typeof (configExport = await loadConfigFromFile(configFilePath))) {
449
449
  let params = {
450
450
  env: getNodeEnv(),
451
451
  command: process.argv[2]
@@ -784,15 +784,12 @@ async function applyCacheConfig({ config, unpackConfig, envFilePaths }) {
784
784
  buildDependencies.userBuildDependencies = cacheConfig.buildDependencies || [], buildDependencies.envFilePaths = envFilePaths;
785
785
  let cacheDirectory = node_path.resolve(unpackConfig.root, cacheConfig.cacheDirectory || `${unpackConfig._context.cachePath}/cache`, utils_isDevServer() ? 'dev' : 'build');
786
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
- }
787
+ cache: {
788
+ type: 'persistent',
789
+ buildDependencies: Object.values(buildDependencies).flat(),
790
+ storage: {
791
+ type: 'filesystem',
792
+ directory: cacheDirectory
796
793
  }
797
794
  }
798
795
  });
@@ -893,7 +890,39 @@ async function getEntry(root, customEntry) {
893
890
  let getOutputFilename = ({ type, hash, async })=>{
894
891
  let FILENAME = utils_isProd() && !1 !== hash ? PROD_DEFAULT_FILENAME : DEV_DEFAULT_FILENAME;
895
892
  return async ? 'js' === type ? FILENAME.jsAsync : FILENAME.cssAsync : FILENAME[type];
896
- };
893
+ }, getCssLoader = (unpackConfig)=>unpackConfig.css?.transformer === 'lightningcss' ? {
894
+ loader: 'builtin:lightningcss-loader',
895
+ options: {
896
+ targets: esVersionToBrowserslist(unpackConfig.build.target),
897
+ ...unpackConfig.css?.lightningcssLoader
898
+ }
899
+ } : {
900
+ loader: getCompiledPkgPath('postcss-loader'),
901
+ options: {
902
+ sourceMap: unpackConfig.css?.sourceMap,
903
+ ...unpackConfig.css?.postcssLoader
904
+ }
905
+ }, getSassLoader = (unpackConfig)=>({
906
+ loader: getCompiledPkgPath('sass-loader'),
907
+ options: {
908
+ api: 'modern-compiler',
909
+ implementation: getUserDepPath(unpackConfig.root, [
910
+ 'sass-embedded',
911
+ 'sass'
912
+ ]),
913
+ sourceMap: unpackConfig.css?.sourceMap,
914
+ ...unpackConfig.css?.sassLoader
915
+ }
916
+ }), getLessLoader = (unpackConfig)=>({
917
+ loader: getCompiledPkgPath('less-loader'),
918
+ options: mergeConfig({
919
+ lessOptions: {
920
+ javascriptEnabled: !0
921
+ },
922
+ implementation: getUserDepPath(unpackConfig.root, 'less'),
923
+ sourceMap: unpackConfig.css?.sourceMap
924
+ }, unpackConfig.css?.lessLoader || {})
925
+ });
897
926
  var css_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
898
927
  async function applyHtmlConfig({ config, unpackConfig }) {
899
928
  let htmlConfig = unpackConfig.html || {}, { template, templateContent } = getHtmlTemplateOrContent(htmlConfig.template, unpackConfig.root), templateParameters = {
@@ -926,7 +955,7 @@ class JsMinifyPlugin {
926
955
  apply(compiler) {
927
956
  let meta = JSON.stringify({
928
957
  name: jsMinify_PLUGIN_NAME,
929
- version: "4.3.0",
958
+ version: "4.5.0",
930
959
  options: this.minifyOptions
931
960
  });
932
961
  compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
@@ -988,11 +1017,9 @@ class Spinner {
988
1017
  class ProgressBar {
989
1018
  prefix = 'transforming';
990
1019
  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();
1020
+ update({ percentage, message = '' }) {
1021
+ let { columns: terminalWidth } = process.stdout, loadingChar = this.spinner.getCurrentChar(), messageWidth = terminalWidth - this.prefix.length - (1 === percentage ? 10 : 9);
1022
+ logUpdate(`${loadingChar} ${this.prefix} (${Math.floor(100 * percentage)}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`), 1 === percentage && clearLine();
996
1023
  }
997
1024
  }
998
1025
  function isLikelyFile(filePath) {
@@ -1054,10 +1081,10 @@ class ProgressLitePlugin {
1054
1081
  class ProgressPlugin extends rspack.ProgressPlugin {
1055
1082
  progressBar = new ProgressBar();
1056
1083
  constructor(){
1057
- super((percentage, msg, ...args)=>{
1084
+ super((percentage, message)=>{
1058
1085
  utils_isProd() && this.progressBar.update({
1059
- current: percentage,
1060
- message: `${msg} ${args.join(' ')}`
1086
+ percentage,
1087
+ message
1061
1088
  });
1062
1089
  });
1063
1090
  }
@@ -1070,13 +1097,39 @@ class ProgressPlugin extends rspack.ProgressPlugin {
1070
1097
  let registerHooks_PLUGIN_NAME = 'RegisterHooksPlugin';
1071
1098
  class RegisterHooksPlugin {
1072
1099
  isFirstCompile = !0;
1073
- lastVirtualModules = new Map();
1100
+ lastLoadedModules = new Map();
1101
+ resolveIdTimings = new Map();
1102
+ loadTimings = new Map();
1074
1103
  isCompiling = !1;
1075
1104
  idleTimer = void 0;
1076
1105
  apply(compiler) {
1077
1106
  let virtualModulesPlugin = new rspack.experiments.VirtualModulesPlugin();
1078
- virtualModulesPlugin.apply(compiler), compiler.hooks.compile.tap(registerHooks_PLUGIN_NAME, ()=>{
1079
- this.isCompiling = !0, applyPluginsByHookSync('buildStart', (impl)=>{
1107
+ virtualModulesPlugin.apply(compiler);
1108
+ let resolveIdPlugins = getNormalizedPluginsByHook('resolveId'), loadPlugins = getNormalizedPluginsByHook('load'), resolveId = async (id, importer)=>{
1109
+ for (let plugin of resolveIdPlugins){
1110
+ let start = performance.now(), result = await plugin.resolveId(id, importer), duration = performance.now() - start;
1111
+ if (this.resolveIdTimings.set(plugin.name, (this.resolveIdTimings.get(plugin.name) || 0) + duration), 'string' == typeof result && result) return result;
1112
+ }
1113
+ return null;
1114
+ }, load = async (id)=>{
1115
+ for (let plugin of loadPlugins){
1116
+ let start = performance.now(), result = await plugin.load(id), duration = performance.now() - start;
1117
+ if (this.loadTimings.set(plugin.name, (this.loadTimings.get(plugin.name) || 0) + duration), 'string' == typeof result) return result;
1118
+ }
1119
+ return null;
1120
+ };
1121
+ (resolveIdPlugins.length > 0 || loadPlugins.length > 0) && compiler.hooks.normalModuleFactory.tap(registerHooks_PLUGIN_NAME, (factory)=>{
1122
+ factory.hooks.beforeResolve.tapPromise(registerHooks_PLUGIN_NAME, async (resolveData)=>{
1123
+ if (!resolveData) return;
1124
+ let request = resolveData.request;
1125
+ if (!request) return;
1126
+ let importer = resolveData.contextInfo?.issuer, resolvedId = await resolveId(request, importer) || request;
1127
+ resolvedId !== request && (resolveData.request = resolvedId);
1128
+ let loaded = await load(resolvedId);
1129
+ null !== loaded && this.lastLoadedModules.get(resolvedId) !== loaded && (this.lastLoadedModules.set(resolvedId, loaded), virtualModulesPlugin.writeModule(resolvedId, loaded));
1130
+ });
1131
+ }), compiler.hooks.compile.tap(registerHooks_PLUGIN_NAME, ()=>{
1132
+ this.isCompiling = !0, this.resolveIdTimings.clear(), this.loadTimings.clear(), applyPluginsByHookSync('buildStart', (impl)=>{
1080
1133
  impl({
1081
1134
  compiler,
1082
1135
  isFirstCompile: this.isFirstCompile,
@@ -1084,15 +1137,14 @@ class RegisterHooksPlugin {
1084
1137
  });
1085
1138
  });
1086
1139
  });
1087
- let updateVirtualModules = ()=>{
1088
- applyPluginsByHookSync('virtualModules', (impl)=>{
1089
- Object.entries(impl()).forEach(([path, content])=>{
1090
- this.lastVirtualModules.get(path) !== content && (this.lastVirtualModules.set(path, content), virtualModulesPlugin.writeModule(path, content));
1091
- });
1092
- });
1140
+ let updateLoadedModules = async ()=>{
1141
+ if (0 !== this.lastLoadedModules.size) for (let [id, prev] of this.lastLoadedModules){
1142
+ let loaded = await load(id);
1143
+ null !== loaded && prev !== loaded && (this.lastLoadedModules.set(id, loaded), virtualModulesPlugin.writeModule(id, loaded));
1144
+ }
1093
1145
  };
1094
1146
  compiler.hooks.thisCompilation.tap(registerHooks_PLUGIN_NAME, (compilation)=>{
1095
- updateVirtualModules(), applyPluginsByHook('processAssets', (impl, plugin)=>{
1147
+ applyPluginsByHookSync('processAssets', (impl, plugin)=>{
1096
1148
  let { stage, handler } = impl;
1097
1149
  compilation.hooks.processAssets.tapPromise({
1098
1150
  name: registerHooks_PLUGIN_NAME,
@@ -1118,6 +1170,8 @@ class RegisterHooksPlugin {
1118
1170
  data.html = 'string' == typeof result ? result : applyHtmlTagDescriptors(data.html, result);
1119
1171
  }), data));
1120
1172
  }), compiler.hooks.finishMake.tap(registerHooks_PLUGIN_NAME, (compilation)=>{
1173
+ if (this.resolveIdTimings.size > 0) for (let [pluginName, total] of this.resolveIdTimings)logger_logger.debug(`${colors.magenta('[plugin]')} ${colors.cyan(pluginName)} ${colors.blue('resolveId')} ${colors.dim('in')} ${colors.yellow(`${total.toFixed(2)}ms`)}`);
1174
+ if (this.loadTimings.size > 0) for (let [pluginName, total] of this.loadTimings)logger_logger.debug(`${colors.magenta('[plugin]')} ${colors.cyan(pluginName)} ${colors.blue('load')} ${colors.dim('in')} ${colors.yellow(`${total.toFixed(2)}ms`)}`);
1121
1175
  let pluginMap = transformTimingMap.get(compilation);
1122
1176
  if (pluginMap) {
1123
1177
  for (let [pluginName, total] of pluginMap)logger_logger.debug(`${colors.magenta('[plugin]')} ${colors.cyan(pluginName)} ${colors.blue('transform')} ${colors.dim('in')} ${colors.yellow(`${total.toFixed(2)}ms`)}`);
@@ -1134,7 +1188,7 @@ class RegisterHooksPlugin {
1134
1188
  }), this.isFirstCompile = !1;
1135
1189
  }), compiler.hooks.afterDone.tap(registerHooks_PLUGIN_NAME, ()=>{
1136
1190
  this.isCompiling = !1, isDev() && (clearTimeout(this.idleTimer), this.idleTimer = setTimeout(()=>{
1137
- this.isCompiling || updateVirtualModules();
1191
+ this.isCompiling || updateLoadedModules();
1138
1192
  }, 50));
1139
1193
  });
1140
1194
  }
@@ -1279,9 +1333,14 @@ async function getBundlerConfig(originalUnpackConfig) {
1279
1333
  {
1280
1334
  test: /\.wasm$/,
1281
1335
  dependency: 'url',
1282
- type: 'asset/resource'
1336
+ type: 'webassembly/async'
1283
1337
  }
1284
- ]
1338
+ ],
1339
+ parser: {
1340
+ javascript: {
1341
+ exportsPresence: 'warn'
1342
+ }
1343
+ }
1285
1344
  },
1286
1345
  plugins: [
1287
1346
  new rspack.DefinePlugin({
@@ -1291,10 +1350,6 @@ async function getBundlerConfig(originalUnpackConfig) {
1291
1350
  ...publicVars,
1292
1351
  ...unpackConfig.define
1293
1352
  }),
1294
- unpackConfig.performance?.removeMomentLocale && new rspack.IgnorePlugin({
1295
- resourceRegExp: /^\.\/locale$/,
1296
- contextRegExp: /moment$/
1297
- }),
1298
1353
  unpackConfig.build?.copy && new rspack.CopyRspackPlugin({
1299
1354
  patterns: unpackConfig.build.copy
1300
1355
  }),
@@ -1335,8 +1390,6 @@ async function getBundlerConfig(originalUnpackConfig) {
1335
1390
  entries: !!unpackConfig.mpa
1336
1391
  },
1337
1392
  experiments: {
1338
- css: !1,
1339
- asyncWebAssembly: !0,
1340
1393
  nativeWatcher: !0
1341
1394
  },
1342
1395
  optimization: {
@@ -1417,11 +1470,6 @@ async function getBundlerConfig(originalUnpackConfig) {
1417
1470
  hash: unpackConfig.build?.filenameHash,
1418
1471
  async: !0
1419
1472
  }), set(config, [
1420
- 'experiments',
1421
- 'css'
1422
- ], !0);
1423
- let sourceMap = unpackConfig.css?.sourceMap;
1424
- set(config, [
1425
1473
  'module',
1426
1474
  'parser',
1427
1475
  'css/module'
@@ -1435,103 +1483,47 @@ async function getBundlerConfig(originalUnpackConfig) {
1435
1483
  localIdentName: CSS_MODULES_LOCAL_IDENT_NAME,
1436
1484
  exportsConvention: CSS_MODULES_EXPORTS_CONVENTION
1437
1485
  });
1438
- let withCssModules = ({ use })=>({
1439
- resourceQuery: /[?&]module(?:[=&]|$)/,
1440
- use: [
1441
- isDev() && {
1442
- loader: node_path.resolve(nativeCss_dirname, './typedCssModulesLoader.js')
1443
- },
1444
- ...use
1445
- ].filter(Boolean),
1446
- type: 'css/module'
1447
- }), getLessLoader = ()=>({
1448
- loader: getCompiledPkgPath('less-loader'),
1449
- options: mergeConfig({
1450
- lessOptions: {
1451
- javascriptEnabled: !0
1452
- },
1453
- implementation: getUserDepPath(unpackConfig.root, 'less'),
1454
- sourceMap
1455
- }, unpackConfig.css?.lessLoader || {})
1456
- }), getCssLoader = ()=>unpackConfig.css?.transformer === 'lightningcss' ? {
1457
- loader: 'builtin:lightningcss-loader',
1458
- options: {
1459
- targets: esVersionToBrowserslist(unpackConfig.build.target),
1460
- ...unpackConfig.css?.lightningcssLoader
1461
- }
1462
- } : {
1463
- loader: getCompiledPkgPath('postcss-loader'),
1464
- options: {
1465
- sourceMap,
1466
- ...unpackConfig.css?.postcssLoader
1467
- }
1468
- }, getSassLoader = ()=>({
1469
- loader: getCompiledPkgPath('sass-loader'),
1470
- options: {
1471
- api: 'modern-compiler',
1472
- implementation: getUserDepPath(unpackConfig.root, [
1473
- 'sass-embedded',
1474
- 'sass'
1475
- ]),
1476
- sourceMap,
1477
- ...unpackConfig.css?.sassLoader
1478
- }
1479
- });
1480
- return config.module.rules.push({
1481
- test: /\.css$/i,
1482
- oneOf: [
1483
- withCssModules({
1484
- use: [
1485
- getCssLoader()
1486
- ]
1487
- }),
1488
- {
1489
- use: [
1490
- getCssLoader()
1491
- ],
1492
- type: 'css'
1493
- }
1494
- ].filter(Boolean)
1495
- }), config.module.rules.push({
1496
- test: /\.less$/i,
1497
- oneOf: [
1498
- withCssModules({
1499
- use: [
1500
- getCssLoader(),
1501
- getLessLoader()
1502
- ]
1503
- }),
1504
- {
1505
- use: [
1506
- getCssLoader(),
1507
- getLessLoader()
1508
- ],
1509
- type: 'css'
1510
- }
1511
- ].filter(Boolean)
1512
- }), config.module.rules.push({
1513
- test: /\.s[ac]ss$/i,
1514
- oneOf: [
1515
- withCssModules({
1516
- use: [
1517
- getCssLoader(),
1518
- getSassLoader()
1519
- ]
1520
- }),
1521
- {
1522
- use: [
1523
- getCssLoader(),
1524
- getSassLoader()
1525
- ],
1526
- type: 'css'
1527
- }
1528
- ].filter(Boolean)
1529
- }), config;
1486
+ let createStyleRule = (test, items)=>{
1487
+ let use = items.filter(Boolean);
1488
+ return {
1489
+ test,
1490
+ oneOf: [
1491
+ (({ use })=>({
1492
+ resourceQuery: /[?&]module(?:[=&]|$)/,
1493
+ use: [
1494
+ isDev() && {
1495
+ loader: node_path.resolve(nativeCss_dirname, './typedCssModulesLoader.js')
1496
+ },
1497
+ ...use
1498
+ ].filter(Boolean),
1499
+ type: 'css/module'
1500
+ }))({
1501
+ use
1502
+ }),
1503
+ {
1504
+ use,
1505
+ type: 'css'
1506
+ }
1507
+ ]
1508
+ };
1509
+ };
1510
+ return config.module.rules.push(createStyleRule(/\.css$/i, [
1511
+ getCssLoader(unpackConfig),
1512
+ unpackConfig.css?.tailwindcss && {
1513
+ loader: require.resolve('@tailwindcss/webpack')
1514
+ }
1515
+ ])), config.module.rules.push(createStyleRule(/\.less$/i, [
1516
+ getCssLoader(unpackConfig),
1517
+ getLessLoader(unpackConfig)
1518
+ ])), config.module.rules.push(createStyleRule(/\.s[ac]ss$/i, [
1519
+ getCssLoader(unpackConfig),
1520
+ getSassLoader(unpackConfig)
1521
+ ])), config;
1530
1522
  }({
1531
1523
  config,
1532
1524
  unpackConfig
1533
1525
  }) : function({ config, unpackConfig }) {
1534
- let sourceMap = unpackConfig.css?.sourceMap, getCommonRules = ({ importLoaders })=>[
1526
+ let getCommonRules = ({ importLoaders })=>[
1535
1527
  utils_isDevServer() ? {
1536
1528
  loader: getCompiledPkgPath('style-loader')
1537
1529
  } : {
@@ -1553,11 +1545,11 @@ async function getBundlerConfig(originalUnpackConfig) {
1553
1545
  exportLocalsConvention: CSS_MODULES_EXPORTS_CONVENTION,
1554
1546
  namedExport: !1
1555
1547
  },
1556
- sourceMap
1548
+ sourceMap: unpackConfig.css?.sourceMap
1557
1549
  }
1558
1550
  }
1559
1551
  ].filter(Boolean);
1560
- utils_isDevServer() || config.plugins.push(new rspack.CssExtractRspackPlugin({
1552
+ return utils_isDevServer() || config.plugins.push(new rspack.CssExtractRspackPlugin({
1561
1553
  filename: getOutputFilename({
1562
1554
  type: 'css',
1563
1555
  hash: unpackConfig.build?.filenameHash
@@ -1568,65 +1560,34 @@ async function getBundlerConfig(originalUnpackConfig) {
1568
1560
  async: !0
1569
1561
  }),
1570
1562
  ignoreOrder: !0
1571
- }));
1572
- let getCssLoader = ()=>unpackConfig.css?.transformer === 'lightningcss' ? {
1573
- loader: 'builtin:lightningcss-loader',
1574
- options: {
1575
- targets: esVersionToBrowserslist(unpackConfig.build.target),
1576
- ...unpackConfig.css?.lightningcssLoader
1577
- }
1578
- } : {
1579
- loader: getCompiledPkgPath('postcss-loader'),
1580
- options: {
1581
- sourceMap,
1582
- ...unpackConfig.css?.postcssLoader
1583
- }
1584
- };
1585
- return config.module.rules.push({
1563
+ })), config.module.rules.push({
1586
1564
  test: /\.less$/i,
1587
1565
  use: [
1588
1566
  ...getCommonRules({
1589
1567
  importLoaders: 2
1590
1568
  }),
1591
- getCssLoader(),
1592
- {
1593
- loader: getCompiledPkgPath('less-loader'),
1594
- options: mergeConfig({
1595
- lessOptions: {
1596
- javascriptEnabled: !0
1597
- },
1598
- implementation: getUserDepPath(unpackConfig.root, 'less'),
1599
- sourceMap
1600
- }, unpackConfig.css?.lessLoader || {})
1601
- }
1569
+ getCssLoader(unpackConfig),
1570
+ getLessLoader(unpackConfig)
1602
1571
  ]
1603
1572
  }), config.module.rules.push({
1604
1573
  test: /\.css$/i,
1605
1574
  use: [
1606
1575
  ...getCommonRules({
1607
- importLoaders: 1
1576
+ importLoaders: unpackConfig.css?.tailwindcss ? 2 : 1
1608
1577
  }),
1609
- getCssLoader()
1610
- ]
1578
+ getCssLoader(unpackConfig),
1579
+ unpackConfig.css?.tailwindcss && {
1580
+ loader: require.resolve('@tailwindcss/webpack')
1581
+ }
1582
+ ].filter(Boolean)
1611
1583
  }), config.module.rules.push({
1612
1584
  test: /\.s[ac]ss$/i,
1613
1585
  use: [
1614
1586
  ...getCommonRules({
1615
1587
  importLoaders: 2
1616
1588
  }),
1617
- getCssLoader(),
1618
- {
1619
- loader: getCompiledPkgPath('sass-loader'),
1620
- options: {
1621
- api: 'modern-compiler',
1622
- implementation: getUserDepPath(unpackConfig.root, [
1623
- 'sass-embedded',
1624
- 'sass'
1625
- ]),
1626
- sourceMap,
1627
- ...unpackConfig.css?.sassLoader
1628
- }
1629
- }
1589
+ getCssLoader(unpackConfig),
1590
+ getSassLoader(unpackConfig)
1630
1591
  ]
1631
1592
  }), config;
1632
1593
  }({
@@ -1809,7 +1770,7 @@ async function unpackDev(unpackConfig) {
1809
1770
  ...middlewares
1810
1771
  ]);
1811
1772
  let server = new RspackDevServer(devServerOptions, compiler);
1812
- await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v4.3.0`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - getUnpackStartTime()))} ${colors.dim('ms')}\n`), printServerUrls({
1773
+ await server.start(), logger_logger.greet(` ${colors.brand(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v4.5.0`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - getUnpackStartTime()))} ${colors.dim('ms')}\n`), printServerUrls({
1813
1774
  port,
1814
1775
  host: unpackConfig.server.host,
1815
1776
  base: unpackConfig.base
@@ -1823,10 +1784,10 @@ async function unpackDev(unpackConfig) {
1823
1784
  function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'unpack' }) {
1824
1785
  let _context = {
1825
1786
  callerName,
1826
- version: "4.3.0",
1787
+ version: "4.5.0",
1827
1788
  cachePath: 'node_modules/.unpack'
1828
1789
  }, resolveConfig = (mode)=>{
1829
- 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, getCustomLayers, optionsFromUnpackConfig, rootPath1, registerCode, namesCode, defaultConfig = {
1790
+ 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 = {
1830
1791
  root: cwd,
1831
1792
  base: '/',
1832
1793
  sourceMap: 'production' !== mode && 'cheap-module-source-map',
@@ -1844,7 +1805,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
1844
1805
  mountId: 'root'
1845
1806
  },
1846
1807
  css: {
1847
- transformer: 'postcss',
1808
+ transformer: 'lightningcss',
1848
1809
  sourceMap: !1
1849
1810
  },
1850
1811
  performance: {
@@ -2404,9 +2365,6 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2404
2365
  optimization: {
2405
2366
  splitChunks: !1
2406
2367
  },
2407
- experiments: {
2408
- css: !0
2409
- },
2410
2368
  externals: depExternals
2411
2369
  });
2412
2370
  compiler.run((_, stats)=>{
@@ -2584,7 +2542,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2584
2542
  let configFile = node_path.join(root, file);
2585
2543
  if (node_fs.existsSync(configFile)) return configFile;
2586
2544
  }
2587
- })(rootDir, configFilePath), configFromOption = mergeConfig(configFromOption, await loadConfigFile(configFilePath)), resolvedDefaults && (configFromOption = mergeConfig(resolvedDefaults, configFromOption)), configFromOption;
2545
+ })(rootDir, configFilePath), configFromOption = mergeConfig(configFromOption, await loadConfigFromFile(configFilePath)), resolvedDefaults && (configFromOption = mergeConfig(resolvedDefaults, configFromOption)), configFromOption;
2588
2546
  }, flushTasks = async ()=>{
2589
2547
  if (!tasks.length) return;
2590
2548
  logger_logger.debug(colors.yellow(`[unocss] Extract token from ${tasks.length} modules.`));
@@ -2619,7 +2577,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2619
2577
  invalidate: ()=>{}
2620
2578
  }), s.hasChanged() && (s = new magic_string(code = restoreSkipCode(s.toString(), skipMap))));
2621
2579
  return code !== original ? code : null;
2622
- }, getCustomLayers = ()=>Array.from(requestedLayers).filter((layer)=>layer !== LAYER_MARK_ALL), {
2580
+ }, {
2623
2581
  name: 'unpack:unocss',
2624
2582
  apply: (config)=>!!config.css?.unocss,
2625
2583
  configResolved: async (config, { cachePath })=>{
@@ -2704,7 +2662,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2704
2662
  if (await flushTasks(), !generated || generated.meta.tokensSize !== tokens.size || generated.meta.layersSize !== requestedLayers.size) {
2705
2663
  let result = await uno.generate(tokens, {
2706
2664
  minify: !0
2707
- }), customLayers = getCustomLayers();
2665
+ }), customLayers = Array.from(requestedLayers).filter((layer)=>layer !== LAYER_MARK_ALL);
2708
2666
  generated = {
2709
2667
  meta: {
2710
2668
  tokensSize: tokens.size,
@@ -2727,10 +2685,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2727
2685
  }
2728
2686
  }
2729
2687
  },
2730
- virtualModules: ()=>({
2731
- [VIRTUAL_UNO_CSS_ID]: getVirtualModuleContent(LAYER_MARK_ALL),
2732
- ...getCustomLayers().reduce((acc, layer)=>(acc[`uno:${layer}.css`] = getVirtualModuleContent(layer), acc), {})
2733
- })
2688
+ load: (id)=>id === VIRTUAL_UNO_CSS_ID ? getVirtualModuleContent(LAYER_MARK_ALL) : id.startsWith('uno:') ? getVirtualModuleContent(id.slice(4, -4)) : null
2734
2689
  }),
2735
2690
  (rootPath1 = '', registerCode = '', namesCode = '', {
2736
2691
  name: 'unpack:svg-icons',
@@ -2751,16 +2706,8 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2751
2706
  registerCode = `const svgDomId = ${JSON.stringify(domId)}\nconst svgHtml = ${JSON.stringify(svg)}\nconst inject = (position) => {\n if (typeof document === 'undefined') return\n if (document.getElementById(svgDomId)) return\n const div = document.createElement('div')\n div.innerHTML = svgHtml\n const svgEl = div.firstElementChild\n if (!svgEl) return\n if (position === 'head' && document.head) {\n document.head.prepend(svgEl)\n return\n }\n const body = document.body\n if (!body) return\n if (position === 'body-first' && body.firstChild) {\n body.insertBefore(svgEl, body.firstChild)\n } else {\n body.appendChild(svgEl)\n }\n}\nconst mount = () => inject(${JSON.stringify(inject)})\nif (typeof document !== 'undefined') {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', mount)\n } else {\n mount()\n }\n}\nexport default mount`, namesCode = `export const svgIconNames = ${JSON.stringify(names)}\nexport default svgIconNames`;
2752
2707
  })();
2753
2708
  },
2754
- virtualModules: ()=>({
2755
- '~svg-icons-register': registerCode || 'export default null',
2756
- '~svg-icons-names': namesCode || 'export default []'
2757
- }),
2758
- transform: {
2759
- filter: {
2760
- test: JS_REGEX
2761
- },
2762
- handler: (code)=>code.includes('virtual:svg-icons-') ? code.replace('virtual:svg-icons-', '~svg-icons-') : null
2763
- }
2709
+ resolveId: (id)=>id.startsWith('virtual:svg-icons-') ? '\0' + id : null,
2710
+ load: (id)=>'\0virtual:svg-icons-register' === id ? registerCode || 'export default null' : '\0virtual:svg-icons-names' === id ? namesCode || 'export default []' : null
2764
2711
  })
2765
2712
  ]
2766
2713
  };
@@ -2774,7 +2721,7 @@ function createUnpack({ cwd = process.cwd(), config: userConfig, callerName = 'u
2774
2721
  let mode = watch ? 'development' : 'production';
2775
2722
  setNodeEnv(mode);
2776
2723
  let config = resolveConfig(mode);
2777
- console.log(colors.brand(`${callerName} v4.3.0`), colors.cyan(`building for ${mode}...`)), await unpackBuild(config);
2724
+ console.log(colors.brand(`${callerName} v4.5.0`), colors.cyan(`building for ${mode}...`)), await unpackBuild(config);
2778
2725
  },
2779
2726
  dev: async ()=>{
2780
2727
  setUnpackStartTime(performance.now());
@@ -2805,8 +2752,10 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
2805
2752
  var injectFramework_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
2806
2753
  async function injectFrameworkPluginForDebug(userConfig) {
2807
2754
  var plugin;
2808
- 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`);
2809
- 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 = [
2755
+ let framework = process.env.FRAMEWORK?.trim();
2756
+ if (!framework) return;
2757
+ let pluginPath = node_path.resolve(injectFramework_dirname, `../../plugin-${framework}/dist/index.js`);
2758
+ 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 = [
2810
2759
  plugin
2811
2760
  ]);
2812
2761
  }
@@ -2923,7 +2872,7 @@ function runCLI() {
2923
2872
  logger_logger.clear(), logger_logger.info(`${node_path.basename(file)} changed, restarting server...`), await watcher.close(), await cleanUpBeforeRestart(), startServer(options);
2924
2873
  });
2925
2874
  });
2926
- 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.3.0"), cli.parse();
2875
+ 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.5.0"), cli.parse();
2927
2876
  }
2928
2877
  var src_CSS_MODULES_NAMED_EXPORT = !1;
2929
- 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, loadConfigFile, 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 };
2878
+ 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 };
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/bundler-config/cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAoC5D,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACN,YAAY,EACZ,YAAY,GACb,EAAE;IACD,MAAM,EAAE,aAAa,CAAA;IACrB,YAAY,EAAE,YAAY,CAAA;IAC1B,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB,GAAG,OAAO,CAAC,aAAa,CAAC,CA0BzB"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/bundler-config/cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAoC5D,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACN,YAAY,EACZ,YAAY,GACb,EAAE;IACD,MAAM,EAAE,aAAa,CAAA;IACrB,YAAY,EAAE,YAAY,CAAA;IAC1B,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB,GAAG,OAAO,CAAC,aAAa,CAAC,CAuBzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/bundler-config/css.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAU,YAAY,EAAE,MAAM,WAAW,CAAA;AAWpE,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,YAAY,GACb,EAAE;IACD,MAAM,EAAE,aAAa,CAAA;IACrB,YAAY,EAAE,YAAY,CAAA;CAC3B,GAAG,aAAa,CAqHhB"}
1
+ {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/bundler-config/css.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAU,YAAY,EAAE,MAAM,WAAW,CAAA;AAUpE,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,YAAY,GACb,EAAE;IACD,MAAM,EAAE,aAAa,CAAA;IACrB,YAAY,EAAE,YAAY,CAAA;CAC3B,GAAG,aAAa,CA4EhB"}