@rsbuild/core 1.6.6 → 1.6.7-canary-57e2a56d-20251120152633

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/476.mjs ADDED
@@ -0,0 +1,8 @@
1
+ import { createRequire } from "node:module";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ let constants_dirname = dirname(fileURLToPath(import.meta.url));
5
+ process.platform, join(constants_dirname), join(constants_dirname, '../static');
6
+ let COMPILED_PATH = join(constants_dirname, '../compiled'), vendors_require = createRequire(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`);
7
+ requireCompiledPackage('picocolors');
8
+ export { requireCompiledPackage };
@@ -1,4 +1,4 @@
1
- import { registerOverlay } from "./hmr";
1
+ import { registerOverlay } from "./hmr.js";
2
2
  function _define_property(obj, key, value) {
3
3
  if (key in obj) Object.defineProperty(obj, key, {
4
4
  value: value,
@@ -9,8 +9,8 @@ function _define_property(obj, key, value) {
9
9
  else obj[key] = value;
10
10
  return obj;
11
11
  }
12
- const { HTMLElement = class {
13
- }, customElements } = 'undefined' != typeof window ? window : globalThis;
12
+ const { HTMLElement: HTMLElement = class {
13
+ }, customElements: customElements } = 'undefined' != typeof window ? window : globalThis;
14
14
  class ErrorOverlay extends HTMLElement {
15
15
  constructor(html){
16
16
  var _root_querySelector, _root_querySelector1;
@@ -1,4 +1,3 @@
1
- let loader_ignoreCssLoader = function(source) {
1
+ export default function(source) {
2
2
  return (this?.cacheable(!0), source.includes('___CSS_LOADER_EXPORT___')) ? '' : source;
3
- };
4
- export { loader_ignoreCssLoader as default };
3
+ }
package/dist/index.cjs CHANGED
@@ -3080,15 +3080,17 @@ ${section.body}` : section.body).join("\n\n"));
3080
3080
  isWatch
3081
3081
  });
3082
3082
  isFirstCompile = !1, await promise;
3083
- }, onEnvironmentDone = async (buildIndex, stats)=>{
3083
+ }, onEnvironmentDone = async (index, stats)=>{
3084
+ let environment = environmentList[index], time = context.buildState.time[environment.name] ?? 0;
3084
3085
  await context.hooks.onAfterEnvironmentCompile.callBatch({
3085
- environment: environmentList[buildIndex].name,
3086
+ environment: environment.name,
3086
3087
  args: [
3087
3088
  {
3088
3089
  isFirstCompile,
3089
3090
  stats,
3090
- environment: environmentList[buildIndex],
3091
- isWatch
3091
+ environment,
3092
+ isWatch,
3093
+ time
3092
3094
  }
3093
3095
  ]
3094
3096
  });
@@ -3130,15 +3132,17 @@ ${section.body}` : section.body).join("\n\n"));
3130
3132
  environments: context.environments
3131
3133
  });
3132
3134
  isFirstCompile = !1, await promise;
3133
- }, onEnvironmentDone = async (buildIndex, stats)=>{
3135
+ }, onEnvironmentDone = async (index, stats)=>{
3136
+ let environment = environmentList[index], time = context.buildState.time[environment.name] ?? 0;
3134
3137
  await context.hooks.onAfterEnvironmentCompile.callBatch({
3135
- environment: environmentList[buildIndex].name,
3138
+ environment: environment.name,
3136
3139
  args: [
3137
3140
  {
3138
3141
  isFirstCompile,
3139
3142
  stats,
3140
- environment: environmentList[buildIndex],
3141
- isWatch: !0
3143
+ environment,
3144
+ isWatch: !0,
3145
+ time
3142
3146
  }
3143
3147
  ]
3144
3148
  });
@@ -3315,7 +3319,6 @@ ${section.body}` : section.body).join("\n\n"));
3315
3319
  function getStatsOptions(compiler, action) {
3316
3320
  let defaultOptions = {
3317
3321
  all: !1,
3318
- timings: !0,
3319
3322
  errors: !0,
3320
3323
  warnings: !0,
3321
3324
  moduleTrace: !0,
@@ -3802,7 +3805,7 @@ ${section.body}` : section.body).join("\n\n"));
3802
3805
  exitHook_callbacks.delete(onExit);
3803
3806
  };
3804
3807
  }
3805
- let addTrailingSlash = (s)=>s.endsWith('/') ? s : `${s}/`, isURL = (str)=>str.startsWith('http') || str.startsWith('//:'), urlJoin = (base, path)=>{
3808
+ let addTrailingSlash = (s)=>s.endsWith('/') ? s : `${s}/`, isURL = (str)=>str.startsWith('http') || str.startsWith('//'), urlJoin = (base, path)=>{
3806
3809
  let [urlProtocol, baseUrl] = base.split('://');
3807
3810
  return `${urlProtocol}://${external_node_path_.posix.join(baseUrl, path)}`;
3808
3811
  }, canParse = (url)=>{
@@ -4162,7 +4165,7 @@ ${section.body}` : section.body).join("\n\n"));
4162
4165
  }
4163
4166
  let browsersListCache = new Map();
4164
4167
  function getBrowserslist(path) {
4165
- let env = process.env.NODE_ENV, cacheKey = path + env;
4168
+ let env = process.env.NODE_ENV, cacheKey = `${path}:${env ?? ''}`;
4166
4169
  if (browsersListCache.has(cacheKey)) return browsersListCache.get(cacheKey);
4167
4170
  let result = loadConfig({
4168
4171
  path,
@@ -4227,7 +4230,7 @@ ${section.body}` : section.body).join("\n\n"));
4227
4230
  async function createContext(options, userConfig) {
4228
4231
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
4229
4232
  return {
4230
- version: "1.6.6",
4233
+ version: "1.6.7-canary-57e2a56d-20251120152633",
4231
4234
  rootPath,
4232
4235
  distPath: '',
4233
4236
  cachePath,
@@ -4245,7 +4248,8 @@ ${section.body}` : section.body).join("\n\n"));
4245
4248
  buildState: {
4246
4249
  stats: null,
4247
4250
  status: 'idle',
4248
- hasErrors: !1
4251
+ hasErrors: !1,
4252
+ time: {}
4249
4253
  }
4250
4254
  };
4251
4255
  }
@@ -4771,7 +4775,7 @@ ${section.body}` : section.body).join("\n\n"));
4771
4775
  let isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
4772
4776
  isVersionLogged || (logger.debug(`using Rspack v${rspack_rspack.rspackVersion}`), isVersionLogged = !0);
4773
4777
  }, lazyModules = new Set();
4774
- return compiler.hooks.infrastructureLog.tap(HOOK_NAME, (name, _, args)=>{
4778
+ compiler.hooks.infrastructureLog.tap(HOOK_NAME, (name, _, args)=>{
4775
4779
  let log = args[0];
4776
4780
  if ('LazyCompilation' === name && 'string' == typeof log && log.startsWith('lazy-compilation-proxy')) {
4777
4781
  let resource = log.split(' ')[0];
@@ -4782,28 +4786,33 @@ ${section.body}` : section.body).join("\n\n"));
4782
4786
  lazyModules.add(relativePath);
4783
4787
  }
4784
4788
  }
4785
- }), compiler.hooks.run.tap(HOOK_NAME, ()=>{
4786
- context.buildState.status = 'building';
4789
+ });
4790
+ let startTime = null;
4791
+ compiler.hooks.run.tap(HOOK_NAME, ()=>{
4792
+ startTime = Date.now(), context.buildState.status = 'building';
4787
4793
  }), compiler.hooks.watchRun.tap(HOOK_NAME, (compiler)=>{
4788
- context.buildState.status = 'building', logRspackVersion(), isCompiling || printBuildLog(compiler, context, lazyModules), lazyModules.size && lazyModules.clear(), isCompiling = !0;
4794
+ startTime = Date.now(), context.buildState.status = 'building', logRspackVersion(), isCompiling || printBuildLog(compiler, context, lazyModules), lazyModules.size && lazyModules.clear(), isCompiling = !0;
4789
4795
  }), compiler.hooks.invalid.tap(HOOK_NAME, ()=>{
4790
4796
  context.buildState.stats = null, context.buildState.status = 'idle', context.buildState.hasErrors = !1;
4791
4797
  }), 'build' === context.action && (isMultiCompiler ? compiler.compilers[0] : compiler).hooks.run.tap(HOOK_NAME, ()=>{
4792
4798
  logger.info('build started...'), logRspackVersion();
4799
+ });
4800
+ let printTime = (index, hasErrors)=>{
4801
+ if (null === startTime) return;
4802
+ let { name } = context.environmentList[index], time = Date.now() - startTime;
4803
+ context.buildState.time[name] = time;
4804
+ let suffix = isMultiCompiler ? color.dim(` (${name})`) : '', timeStr = `${prettyTime(time / 1000)}${suffix}`;
4805
+ hasErrors ? logger.error(`build failed in ${timeStr}`) : logger.ready(`built in ${timeStr}`);
4806
+ };
4807
+ return isMultiCompiler && compiler.compilers.forEach((item, index)=>{
4808
+ item.hooks.done.tap(HOOK_NAME, (stats)=>{
4809
+ printTime(index, stats.hasErrors());
4810
+ });
4793
4811
  }), compiler.hooks.done.tap(HOOK_NAME, (statsInstance)=>{
4794
4812
  let stats = getRsbuildStats(statsInstance, compiler, context.action), hasErrors = statsInstance.hasErrors();
4795
4813
  context.buildState.stats = stats, context.buildState.status = 'done', context.buildState.hasErrors = hasErrors, context.socketServer?.onBuildDone();
4796
- let printTime = (statsItem, index)=>{
4797
- if (statsItem.time) {
4798
- let time = prettyTime(statsItem.time / 1000), { name } = rspackConfigs[index], suffix = name && isMultiCompiler ? color.dim(` (${name})`) : '';
4799
- logger.ready(`built in ${time}${suffix}`);
4800
- }
4801
- };
4802
- hasErrors || (isMultiCompiler && stats.children?.length ? stats.children.forEach((item, index)=>{
4803
- printTime(item, index);
4804
- }) : printTime(stats, 0));
4805
4814
  let { message, level } = formatStats(stats, hasErrors);
4806
- 'error' === level && logger.error(message), 'warning' === level && logger.warn(message), isCompiling = !1;
4815
+ 'error' === level && logger.error(message), 'warning' === level && logger.warn(message), isMultiCompiler || printTime(0, hasErrors), isCompiling = !1;
4807
4816
  }), 'dev' === context.action && registerDevHook({
4808
4817
  context,
4809
4818
  compiler,
@@ -4912,8 +4921,13 @@ ${section.body}` : section.body).join("\n\n"));
4912
4921
  }).set('generator', generatorOptions);
4913
4922
  };
4914
4923
  function getRegExpForExts(exts) {
4915
- let matcher = exts.map((ext)=>ext.trim()).map((ext)=>ext.startsWith('.') ? ext.slice(1) : ext).join('|');
4916
- return RegExp(1 === exts.length ? `\\.${matcher}$` : `\\.(?:${matcher})$`, 'i');
4924
+ let normalizedExts = [];
4925
+ for (let ext of exts){
4926
+ let trimmed = ext.trim();
4927
+ normalizedExts.push(trimmed.startsWith('.') ? trimmed.slice(1) : trimmed);
4928
+ }
4929
+ let matcher = normalizedExts.join('|');
4930
+ return RegExp(1 === normalizedExts.length ? `\\.${matcher}$` : `\\.(?:${matcher})$`, 'i');
4917
4931
  }
4918
4932
  let isUseAnalyzer = (config)=>process.env.BUNDLE_ANALYZE || config.performance?.bundleAnalyze;
4919
4933
  function pluginBundleAnalyzer() {
@@ -4967,7 +4981,7 @@ ${section.body}` : section.body).join("\n\n"));
4967
4981
  function getCacheDirectory({ cacheDirectory }, context) {
4968
4982
  return cacheDirectory ? (0, external_node_path_.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, external_node_path_.join)(context.rootPath, cacheDirectory) : (0, external_node_path_.join)(context.cachePath, context.bundlerType);
4969
4983
  }
4970
- async function getBuildDependencies(context, config, environmentContext, userBuildDependencies) {
4984
+ async function getBuildDependencies(context, config, environmentContext, additionalDependencies) {
4971
4985
  let rootPackageJson = (0, external_node_path_.join)(context.rootPath, 'package.json'), browserslistConfig = (0, external_node_path_.join)(context.rootPath, '.browserslistrc'), buildDependencies = {};
4972
4986
  await isFileExists(rootPackageJson) && (buildDependencies.packageJson = [
4973
4987
  rootPackageJson
@@ -4988,10 +5002,7 @@ ${section.body}` : section.body).join("\n\n"));
4988
5002
  ].map((ext)=>(0, external_node_path_.join)(context.rootPath, `tailwind.config.${ext}`)));
4989
5003
  return tailwindConfig && (buildDependencies.tailwindcss = [
4990
5004
  tailwindConfig
4991
- ]), {
4992
- ...buildDependencies,
4993
- ...userBuildDependencies
4994
- };
5005
+ ]), additionalDependencies && (buildDependencies.additional = additionalDependencies), buildDependencies;
4995
5006
  }
4996
5007
  let addTrailingSep = (dir)=>dir.endsWith(external_node_path_.sep) ? dir : dir + external_node_path_.sep, isStrictSubdir = (parent, child)=>{
4997
5008
  let parentDir = addTrailingSep(parent), childDir = addTrailingSep(child);
@@ -5062,8 +5073,9 @@ ${section.body}` : section.body).join("\n\n"));
5062
5073
  },
5063
5074
  config: config.tools.postcss,
5064
5075
  ctx: {
5065
- addPlugins (plugins) {
5066
- extraPlugins.push(...helpers_castArray(plugins));
5076
+ addPlugins (plugins, options = {}) {
5077
+ let { order = 'post' } = options, list = helpers_castArray(plugins);
5078
+ 'pre' === order ? extraPlugins.unshift(...list) : extraPlugins.push(...list);
5067
5079
  }
5068
5080
  }
5069
5081
  });
@@ -8305,8 +8317,16 @@ ${section.body}` : section.body).join("\n\n"));
8305
8317
  };
8306
8318
  preEntry.forEach(addEntry), injectCoreJsEntry && addEntry(createVirtualModule('import "core-js";')), helpers_castArray(entry[entryName]).forEach(addEntry);
8307
8319
  }
8308
- }), api.onBeforeCreateCompiler(({ bundlerConfigs })=>{
8309
- if (bundlerConfigs.every((config)=>!config.entry)) throw Error(`${color.dim('[rsbuild:config]')} Could not find any entry module, please make sure that ${color.yellow('src/index.(ts|js|tsx|jsx|mts|cts|mjs|cjs)')} exists, or customize entry through the ${color.yellow('source.entry')} configuration.`);
8320
+ }), api.onBeforeCreateCompiler({
8321
+ order: 'post',
8322
+ handler: ({ bundlerConfigs })=>{
8323
+ if (bundlerConfigs.some((config)=>config.entry)) return;
8324
+ let isModuleFederationPlugin = (plugin)=>isObject(plugin) && 'ModuleFederationPlugin' === plugin.constructor.name;
8325
+ if (bundlerConfigs.some(({ plugins })=>plugins?.some(isModuleFederationPlugin))) return void bundlerConfigs.forEach((config)=>{
8326
+ config.entry = {};
8327
+ });
8328
+ throw Error(`${color.dim('[rsbuild:config]')} Could not find any entry module, please make sure that ${color.yellow('src/index.(ts|js|tsx|jsx|mts|cts|mjs|cjs)')} exists, or customize entry through the ${color.yellow('source.entry')} configuration.`);
8329
+ }
8310
8330
  });
8311
8331
  }
8312
8332
  },
@@ -8357,9 +8377,7 @@ ${section.body}` : section.body).join("\n\n"));
8357
8377
  let { config } = environment, { bundlerType } = api.context, buildCache = config.performance.buildCache ?? 'webpack' === bundlerType;
8358
8378
  if (!1 === buildCache) return;
8359
8379
  cacheEnabled = !0;
8360
- let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = getCacheDirectory(cacheConfig, context), buildDependencies = await getBuildDependencies(context, config, environment, cacheConfig.buildDependencies ? {
8361
- userBuildDependencies: cacheConfig.buildDependencies
8362
- } : {});
8380
+ let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = getCacheDirectory(cacheConfig, context), buildDependencies = await getBuildDependencies(context, config, environment, cacheConfig.buildDependencies);
8363
8381
  'webpack' === bundlerType && await validateWebpackCache(cacheDirectory, buildDependencies);
8364
8382
  let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${await helpers_hash(JSON.stringify(cacheConfig.cacheDigest))}` : `${environment.name}-${env}`;
8365
8383
  'rspack' === bundlerType ? (chain.cache(!0), chain.experiments({
@@ -9841,7 +9859,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
9841
9859
  };
9842
9860
  function setupCommands() {
9843
9861
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9844
- cli.version("1.6.6"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9862
+ cli.version("1.6.7-canary-57e2a56d-20251120152633"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9845
9863
  default: 'auto'
9846
9864
  }).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
9847
9865
  type: [
@@ -9910,7 +9928,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
9910
9928
  }
9911
9929
  function showGreeting() {
9912
9930
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9913
- logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.6\n`);
9931
+ logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.7-canary-57e2a56d-20251120152633\n`);
9914
9932
  }
9915
9933
  function setupLogLevel() {
9916
9934
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9931,7 +9949,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
9931
9949
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
9932
9950
  }
9933
9951
  }
9934
- let src_version = "1.6.6";
9952
+ let src_version = "1.6.7-canary-57e2a56d-20251120152633";
9935
9953
  })(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defaultAllowedOrigins = __webpack_exports__.defaultAllowedOrigins, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
9936
9954
  "PLUGIN_CSS_NAME",
9937
9955
  "PLUGIN_SWC_NAME",