@rsbuild/core 2.0.13 → 2.0.15

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.
@@ -1 +1 @@
1
- {"name":"rspack-chain","version":"2.0.2","license":"MIT","types":"types/index.d.ts","type":"module"}
1
+ {"name":"rspack-chain","version":"2.1.0","license":"MIT","types":"types/index.d.ts","type":"module"}
@@ -1,4 +1,8 @@
1
- import { Configuration, RuleSetRule } from '@rspack/core';
1
+ import type {
2
+ Configuration,
3
+ RuleSetLoaderWithOptions,
4
+ RuleSetRule,
5
+ } from '@rspack/core';
2
6
 
3
7
  // The compiler type of Rspack / webpack are mismatch,
4
8
  // so we use a loose type here to allow using webpack plugins.
@@ -82,12 +86,14 @@ export declare class RspackChain extends __Config.ChainedMap<void> {
82
86
  bail(value: RspackConfig['bail']): this;
83
87
  cache(value: RspackConfig['cache']): this;
84
88
  dependencies(value: RspackConfig['dependencies']): this;
89
+ extends(value: RspackConfig['extends']): this;
85
90
  ignoreWarnings(value: RspackConfig['ignoreWarnings']): this;
86
91
  loader(value: RspackConfig['loader']): this;
87
92
  name(value: RspackConfig['name']): this;
88
93
  infrastructureLogging(value: RspackConfig['infrastructureLogging']): this;
89
94
  snapshot(value: RspackConfig['snapshot']): this;
90
95
  lazyCompilation(value: RspackConfig['lazyCompilation']): this;
96
+ incremental(value: RspackConfig['incremental']): this;
91
97
 
92
98
  entry(name: string): RspackChain.EntryPoint;
93
99
  plugin(name: string): RspackChain.Plugin<this, PluginInstance>;
@@ -166,9 +172,11 @@ export declare namespace RspackChain {
166
172
  type RspackModule = Required<NonNullable<Configuration['module']>>;
167
173
 
168
174
  class Module extends ChainedMap<RspackChain> {
175
+ defaultRules: TypedChainedMap<this, { [key: string]: Rule }>;
169
176
  rules: TypedChainedMap<this, { [key: string]: Rule }>;
170
177
  generator: ChainedMap<this>;
171
178
  parser: ChainedMap<this>;
179
+ defaultRule(name: string): Rule;
172
180
  rule(name: string): Rule;
173
181
  noParse(value: RspackModule['noParse']): this;
174
182
  }
@@ -177,6 +185,7 @@ export declare namespace RspackChain {
177
185
 
178
186
  class Output extends ChainedMap<RspackChain> {
179
187
  assetModuleFilename(value: RspackOutput['assetModuleFilename']): this;
188
+ asyncChunks(value: RspackOutput['asyncChunks']): this;
180
189
  bundlerInfo(value: RspackOutput['bundlerInfo']): this;
181
190
  chunkFilename(value: RspackOutput['chunkFilename']): this;
182
191
  chunkLoadTimeout(value: RspackOutput['chunkLoadTimeout']): this;
@@ -184,6 +193,8 @@ export declare namespace RspackChain {
184
193
  chunkLoading(value: RspackOutput['chunkLoading']): this;
185
194
  chunkFormat(value: RspackOutput['chunkFormat']): this;
186
195
  crossOriginLoading(value: RspackOutput['crossOriginLoading']): this;
196
+ cssChunkFilename(value: RspackOutput['cssChunkFilename']): this;
197
+ cssFilename(value: RspackOutput['cssFilename']): this;
187
198
  devtoolFallbackModuleFilenameTemplate(
188
199
  value: RspackOutput['devtoolFallbackModuleFilenameTemplate'],
189
200
  ): this;
@@ -206,6 +217,7 @@ export declare namespace RspackChain {
206
217
  hotUpdateMainFilename(value: RspackOutput['hotUpdateMainFilename']): this;
207
218
  library(value: RspackOutput['library']): this;
208
219
  importFunctionName(value: RspackOutput['importFunctionName']): this;
220
+ importMetaName(value: RspackOutput['importMetaName']): this;
209
221
  path(value: RspackOutput['path']): this;
210
222
  pathinfo(value: RspackOutput['pathinfo']): this;
211
223
  publicPath(value: RspackOutput['publicPath']): this;
@@ -217,7 +229,10 @@ export declare namespace RspackChain {
217
229
  strictModuleExceptionHandling(
218
230
  value: RspackOutput['strictModuleExceptionHandling'],
219
231
  ): this;
232
+ trustedTypes(value: RspackOutput['trustedTypes']): this;
220
233
  workerChunkLoading(value: RspackOutput['workerChunkLoading']): this;
234
+ workerPublicPath(value: RspackOutput['workerPublicPath']): this;
235
+ workerWasmLoading(value: RspackOutput['workerWasmLoading']): this;
221
236
  enabledLibraryTypes(value: RspackOutput['enabledLibraryTypes']): this;
222
237
  environment(value: RspackOutput['environment']): this;
223
238
  compareBeforeEmit(value: RspackOutput['compareBeforeEmit']): this;
@@ -243,6 +258,7 @@ export declare namespace RspackChain {
243
258
 
244
259
  class DevServer extends TypedChainedMap<RspackChain, RspackDevServer> {}
245
260
 
261
+ // rslint-disable-next-line @typescript-eslint/no-empty-object-type
246
262
  interface DevServer extends DevServerShorthandMethods<DevServer> {}
247
263
 
248
264
  type RspackPerformance = Exclude<
@@ -289,16 +305,15 @@ export declare namespace RspackChain {
289
305
  >;
290
306
  byDependency: TypedChainedMap<this, RspackResolve['byDependency']>;
291
307
  enforceExtension(value: RspackResolve['enforceExtension']): this;
308
+ fullySpecified(value: RspackResolve['fullySpecified']): this;
309
+ pnp(value: RspackResolve['pnp']): this;
292
310
  symlinks(value: RspackResolve['symlinks']): this;
293
311
  preferRelative(value: RspackResolve['preferRelative']): this;
294
312
  preferAbsolute(value: RspackResolve['preferAbsolute']): this;
295
313
 
296
314
  tsConfig(value: RspackResolve['tsConfig']): this;
297
315
  }
298
-
299
- class RuleResolve<T = RspackChain> extends Resolve<T> {
300
- fullySpecified(value: boolean): this;
301
- }
316
+ class RuleResolve<T = RspackChain> extends Resolve<T> {}
302
317
 
303
318
  class ResolveLoader extends Resolve {
304
319
  modules: ChainedSet<this>;
@@ -317,16 +332,20 @@ export declare namespace RspackChain {
317
332
  resolve: RuleResolve<Rule<T>>;
318
333
 
319
334
  dependency(value: RspackRuleSet['dependency']): this;
335
+ descriptionData(value: RspackRuleSet['descriptionData']): this;
320
336
  enforce(value: RspackRuleSet['enforce']): this;
337
+ extractSourceMap(value: RspackRuleSet['extractSourceMap']): this;
321
338
  issuer(value: RspackRuleSet['issuer']): this;
322
339
  issuerLayer(value: RspackRuleSet['issuerLayer']): this;
323
340
  layer(value: RspackRuleSet['layer']): this;
324
341
  mimetype(value: RspackRuleSet['mimetype']): this;
342
+ phase(value: RspackRuleSet['phase']): this;
325
343
  parser(value: RspackRuleSet['parser']): this;
326
344
  generator(value: RspackRuleSet['generator']): this;
327
345
  resource(value: RspackRuleSet['resource']): this;
328
346
  resourceFragment(value: RspackRuleSet['resourceFragment']): this;
329
347
  resourceQuery(value: RspackRuleSet['resourceQuery']): this;
348
+ scheme(value: RspackRuleSet['scheme']): this;
330
349
  sideEffects(value: RspackRuleSet['sideEffects']): this;
331
350
  with(value: RspackRuleSet['with']): this;
332
351
  test(value: RspackRuleSet['test']): this;
@@ -386,10 +405,15 @@ export declare namespace RspackChain {
386
405
  [name: string]: any;
387
406
  }
388
407
 
408
+ type LoaderParallelOptions = NonNullable<
409
+ RuleSetLoaderWithOptions['parallel']
410
+ >;
411
+
389
412
  class Use<Parent = Rule> extends ChainedMap<Parent> implements Orderable {
413
+ ident(value: NonNullable<RuleSetLoaderWithOptions['ident']>): this;
390
414
  loader(value: string): this;
391
415
  options(value: LoaderOptions): this;
392
- parallel(value: boolean): this;
416
+ parallel(value: LoaderParallelOptions): this;
393
417
 
394
418
  tap(f: (options: LoaderOptions) => LoaderOptions): this;
395
419
 
package/dist/349.js ADDED
@@ -0,0 +1,10 @@
1
+ let CSS_MODULE_REGEX = /\.module(s)?\.\w+$/i, CSS_ICSS_REGEX = /\.icss\.\w+$/i, isCSSModules = (modules, loaderContext)=>{
2
+ if (!modules) return !1;
3
+ if (!0 === modules || 'string' == typeof modules) return !0;
4
+ let { auto } = modules;
5
+ if (void 0 === auto) return !0;
6
+ if (!1 === auto) return !1;
7
+ let resourcePath = loaderContext._module?.matchResource || loaderContext.resourcePath;
8
+ return auto instanceof RegExp ? auto.test(resourcePath) : 'function' == typeof auto ? auto(resourcePath, loaderContext.resourceQuery, loaderContext.resourceFragment) : CSS_MODULE_REGEX.test(resourcePath) || CSS_ICSS_REGEX.test(resourcePath);
9
+ };
10
+ export { isCSSModules };
package/dist/756.js CHANGED
@@ -1788,6 +1788,8 @@ let ChainedMap = createMap(createChainable(Object)), ChainedValueMap = (superCla
1788
1788
  this[key] = new ChainedSet(this);
1789
1789
  }), this.extend([
1790
1790
  'enforceExtension',
1791
+ 'fullySpecified',
1792
+ 'pnp',
1791
1793
  'symlinks',
1792
1794
  'preferRelative',
1793
1795
  'preferAbsolute',
@@ -1846,6 +1848,7 @@ let ChainedMap = createMap(createChainable(Object)), ChainedValueMap = (superCla
1846
1848
  constructor(parent){
1847
1849
  super(parent), this.extend([
1848
1850
  'assetModuleFilename',
1851
+ 'asyncChunks',
1849
1852
  'bundlerInfo',
1850
1853
  'chunkFilename',
1851
1854
  'chunkLoadTimeout',
@@ -1854,6 +1857,8 @@ let ChainedMap = createMap(createChainable(Object)), ChainedValueMap = (superCla
1854
1857
  'chunkFormat',
1855
1858
  'enabledChunkLoadingTypes',
1856
1859
  'crossOriginLoading',
1860
+ 'cssChunkFilename',
1861
+ 'cssFilename',
1857
1862
  'devtoolFallbackModuleFilenameTemplate',
1858
1863
  'devtoolModuleFilenameTemplate',
1859
1864
  'devtoolNamespace',
@@ -1869,6 +1874,7 @@ let ChainedMap = createMap(createChainable(Object)), ChainedValueMap = (superCla
1869
1874
  'hotUpdateMainFilename',
1870
1875
  'library',
1871
1876
  'importFunctionName',
1877
+ 'importMetaName',
1872
1878
  'path',
1873
1879
  'pathinfo',
1874
1880
  'publicPath',
@@ -1876,7 +1882,10 @@ let ChainedMap = createMap(createChainable(Object)), ChainedValueMap = (superCla
1876
1882
  'sourceMapFilename',
1877
1883
  'strictModuleErrorHandling',
1878
1884
  'strictModuleExceptionHandling',
1885
+ 'trustedTypes',
1879
1886
  'workerChunkLoading',
1887
+ 'workerPublicPath',
1888
+ 'workerWasmLoading',
1880
1889
  'enabledLibraryTypes',
1881
1890
  'environment',
1882
1891
  'compareBeforeEmit',
@@ -1983,6 +1992,7 @@ let ChainedMap = createMap(createChainable(Object)), ChainedValueMap = (superCla
1983
1992
  }), Use = Orderable(class extends ChainedMap {
1984
1993
  constructor(parent, name){
1985
1994
  super(parent), this.name = name, this.extend([
1995
+ 'ident',
1986
1996
  'loader',
1987
1997
  'options',
1988
1998
  'parallel'
@@ -2023,20 +2033,22 @@ let Rule = Orderable(class extends ChainedMap {
2023
2033
  super(parent), this.ruleName = name, this.names = [], this.ruleType = ruleType, this.ruleTypes = [];
2024
2034
  let rule = this;
2025
2035
  for(; rule instanceof Rule;)this.names.unshift(rule.ruleName), this.ruleTypes.unshift(rule.ruleType), rule = rule.parent;
2026
- this.uses = new ChainedMap(this), this.include = new ChainedSet(this), this.exclude = new ChainedSet(this), this.rules = new ChainedMap(this), this.oneOfs = new ChainedMap(this), this.resolve = new Resolve(this), this.resolve.extend([
2027
- 'fullySpecified'
2028
- ]), this.extend([
2036
+ this.uses = new ChainedMap(this), this.include = new ChainedSet(this), this.exclude = new ChainedSet(this), this.rules = new ChainedMap(this), this.oneOfs = new ChainedMap(this), this.resolve = new Resolve(this), this.extend([
2029
2037
  'dependency',
2038
+ "descriptionData",
2030
2039
  'enforce',
2040
+ 'extractSourceMap',
2031
2041
  'issuer',
2032
2042
  'issuerLayer',
2033
2043
  'layer',
2034
2044
  'mimetype',
2045
+ 'phase',
2035
2046
  'parser',
2036
2047
  'generator',
2037
2048
  'resource',
2038
2049
  'resourceFragment',
2039
2050
  'resourceQuery',
2051
+ 'scheme',
2040
2052
  'sideEffects',
2041
2053
  'with',
2042
2054
  'test',
@@ -2182,12 +2194,14 @@ class RspackChain extends ChainedMap {
2182
2194
  'bail',
2183
2195
  'cache',
2184
2196
  'dependencies',
2197
+ 'extends',
2185
2198
  'ignoreWarnings',
2186
2199
  'loader',
2187
2200
  'name',
2188
2201
  'infrastructureLogging',
2189
2202
  'snapshot',
2190
- 'lazyCompilation'
2203
+ 'lazyCompilation',
2204
+ 'incremental'
2191
2205
  ]);
2192
2206
  }
2193
2207
  static toString(config, { verbose = !1, configPrefix = 'config' } = {}) {
@@ -3483,7 +3497,7 @@ function createPublicContext(context) {
3483
3497
  async function createContext(options, userConfig, logger) {
3484
3498
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
3485
3499
  return {
3486
- version: "2.0.13",
3500
+ version: "2.0.15",
3487
3501
  rootPath,
3488
3502
  distPath: '',
3489
3503
  cachePath,
@@ -6680,7 +6694,7 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
6680
6694
  }
6681
6695
  async function setupOutputFileSystem(writeToDisk, compilers) {
6682
6696
  if (!0 !== writeToDisk) {
6683
- let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.57.6/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
6697
+ let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.57.7/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
6684
6698
  for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
6685
6699
  }
6686
6700
  let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
@@ -7343,7 +7357,12 @@ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls,
7343
7357
  rl.close();
7344
7358
  };
7345
7359
  }
7346
- let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xml/i;
7360
+ let createDeferred = ()=>{
7361
+ let deferred = {};
7362
+ return deferred.promise = new Promise((resolve)=>{
7363
+ deferred.resolve = resolve;
7364
+ }), deferred;
7365
+ }, ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xml/i;
7347
7366
  function gzipMiddleware_gzipMiddleware({ filter, level = node_zlib.constants.Z_BEST_SPEED } = {}) {
7348
7367
  return function gzipMiddleware(req, res, next) {
7349
7368
  let gzip, writeHeadStatus, writeHeadMessage;
@@ -8065,7 +8084,8 @@ async function startWatchFiles({ paths, options, type = 'reload-page' }, buildMa
8065
8084
  }), watcher;
8066
8085
  }
8067
8086
  async function devServer_createDevServer(options, createCompiler, config, { getPortSilently, runCompile = !0 } = {}) {
8068
- let lastStats, { context } = options, { logger } = context;
8087
+ var environmentCount;
8088
+ let stats, waiters, { context } = options, { logger } = context;
8069
8089
  logger.debug('create dev server');
8070
8090
  let { port, portTip } = await resolvePort(config), { middlewareMode, host } = config.server, isHttps = !!config.server.https, routes = getRoutes(context), fallbackPathname = 0 === routes.length && context.environmentList.some((item)=>'web' === item.config.output.target) ? config.server.base : void 0;
8071
8091
  context.devServer = {
@@ -8073,24 +8093,40 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
8073
8093
  port,
8074
8094
  https: isHttps
8075
8095
  };
8076
- let waitLastCompileDoneResolve = null, waitLastCompileDone = new Promise((resolve)=>{
8077
- waitLastCompileDoneResolve = resolve;
8078
- });
8079
- context.hooks.onAfterDevCompile.tap(({ stats })=>{
8080
- lastStats = 'stats' in stats ? stats.stats : [
8081
- stats
8082
- ], waitLastCompileDoneResolve && (waitLastCompileDoneResolve(), waitLastCompileDoneResolve = null);
8083
- });
8084
- let startCompile = async ()=>{
8096
+ let compileState = (stats = Array(environmentCount = context.environmentList.length), waiters = Array.from({
8097
+ length: environmentCount
8098
+ }, createDeferred), {
8099
+ reset (index) {
8100
+ stats[index] && (stats[index] = void 0, waiters[index] = createDeferred());
8101
+ },
8102
+ done (index, nextStats) {
8103
+ stats[index] = nextStats, waiters[index].resolve(nextStats);
8104
+ },
8105
+ async wait (index) {
8106
+ let currentStats = stats[index];
8107
+ return currentStats || waiters[index].promise;
8108
+ }
8109
+ }), startCompile = async ()=>{
8085
8110
  let compiler = await createCompiler();
8086
8111
  if (!compiler) throw Error(`${color.dim('[rsbuild:server]')} Failed to get compiler instance.`);
8087
8112
  context.publicPathnames = getPublicPathnames(compiler_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
8088
8113
  getPublicPathFromCompiler(compiler)
8089
- ], config.server.base), compiler?.hooks.watchRun.tap('rsbuild:watchRun', ()=>{
8090
- lastStats && (waitLastCompileDoneResolve && (waitLastCompileDoneResolve(), waitLastCompileDoneResolve = null), waitLastCompileDone = new Promise((resolve)=>{
8091
- waitLastCompileDoneResolve = resolve;
8092
- }));
8093
- });
8114
+ ], config.server.base);
8115
+ let hookOptions = {
8116
+ name: 'rsbuild:environment-api',
8117
+ stage: -10000
8118
+ };
8119
+ compiler_isMultiCompiler(compiler) ? compiler.compilers.forEach((compiler, index)=>{
8120
+ compiler.hooks.watchRun.tap(hookOptions, ()=>{
8121
+ compileState.reset(index);
8122
+ }), compiler.hooks.done.tap(hookOptions, (stats)=>{
8123
+ compileState.done(index, stats);
8124
+ });
8125
+ }) : (compiler.hooks.watchRun.tap(hookOptions, ()=>{
8126
+ compileState.reset(0);
8127
+ }), compiler.hooks.done.tap(hookOptions, (stats)=>{
8128
+ compileState.done(0, stats);
8129
+ }));
8094
8130
  let buildManager = new BuildManager({
8095
8131
  context,
8096
8132
  config,
@@ -8160,18 +8196,18 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
8160
8196
  },
8161
8197
  getStats: async ()=>{
8162
8198
  if (!state.buildManager) throw Error(getErrorMsg('getStats'));
8163
- return await waitLastCompileDone, lastStats[index];
8199
+ return compileState.wait(index);
8164
8200
  },
8165
8201
  loadBundle: async (entryName)=>{
8166
8202
  if (!state.buildManager) throw Error(getErrorMsg('loadBundle'));
8167
- return await waitLastCompileDone, cacheableLoadBundle(lastStats[index], entryName, {
8203
+ return cacheableLoadBundle(await compileState.wait(index), entryName, {
8168
8204
  readFileSync: state.buildManager.readFileSync,
8169
8205
  environment
8170
8206
  });
8171
8207
  },
8172
8208
  getTransformedHtml: async (entryName)=>{
8173
8209
  if (!state.buildManager) throw Error(getErrorMsg('getTransformedHtml'));
8174
- return await waitLastCompileDone, cacheableTransformedHtml(lastStats[index], entryName, {
8210
+ return cacheableTransformedHtml(await compileState.wait(index), entryName, {
8175
8211
  readFileSync: state.buildManager.readFileSync,
8176
8212
  environment
8177
8213
  });
@@ -8357,10 +8393,7 @@ function applyDefaultPlugins(pluginManager, context) {
8357
8393
  level: 'error'
8358
8394
  }), chain.watchOptions({
8359
8395
  aggregateTimeout: 0
8360
- }), chain.performance.hints(!1), chain.experiments({
8361
- ...chain.get('experiments'),
8362
- pureFunctions: !0
8363
- }), chain.module.parser.merge({
8396
+ }), chain.performance.hints(!1), chain.module.parser.merge({
8364
8397
  javascript: {
8365
8398
  typeReexportsPresence: 'tolerant'
8366
8399
  }
@@ -9040,7 +9073,9 @@ try {
9040
9073
  } : {
9041
9074
  ...cssLoaderOptions,
9042
9075
  importLoaders: importLoaders.normal
9043
- }, rule.use(CHAIN_ID.USE.CSS).options(finalOptions), 'url' !== type && rule.sideEffects(!0), rule.resolve.preferRelative(!0);
9076
+ }, emitCss || 'main' !== type || rule.use(CHAIN_ID.USE.IGNORE_CSS).options({
9077
+ modules: finalOptions.modules
9078
+ }), rule.use(CHAIN_ID.USE.CSS).options(finalOptions), 'url' !== type && rule.sideEffects(!0), rule.resolve.preferRelative(!0);
9044
9079
  });
9045
9080
  let cssUrlFilename = getFilename(config, 'css', isProd), cssUrlPath = config.output.distPath.css;
9046
9081
  urlRule.use(CHAIN_ID.USE.CSS_URL).options({
@@ -9970,7 +10005,7 @@ let applyServerOptions = (command)=>{
9970
10005
  };
9971
10006
  function setupCommands() {
9972
10007
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9973
- cli.version("2.0.13"), 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)', {
10008
+ cli.version("2.0.15"), 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)', {
9974
10009
  default: 'auto'
9975
10010
  }).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', {
9976
10011
  type: [
@@ -10041,7 +10076,7 @@ function initNodeEnv(command) {
10041
10076
  }
10042
10077
  function showGreeting() {
10043
10078
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
10044
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.13\n`);
10079
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.15\n`);
10045
10080
  }
10046
10081
  function setupLogLevel() {
10047
10082
  if (cli_argv.length <= 3) return;
@@ -10063,5 +10098,5 @@ function runCLI() {
10063
10098
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
10064
10099
  }
10065
10100
  }
10066
- let src_version = "2.0.13";
10101
+ let src_version = "2.0.15";
10067
10102
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, mrmime_lookup, runCLI, src_logger as logger, src_version as version };
@@ -1,15 +1,11 @@
1
1
  import node_path from "node:path";
2
- let CSS_MODULE_REGEX = /\.module\.\w+$/i, HASH_PLACEHOLDER_REGEX = /\[(?:[^:\]]+:)?(?:chunkhash|contenthash|hash|fullhash)(?::[^\]]+)?]/i, getRelativePath = (root, resourcePath)=>{
2
+ import { isCSSModules } from "./349.js";
3
+ let HASH_PLACEHOLDER_REGEX = /\[(?:[^:\]]+:)?(?:chunkhash|contenthash|hash|fullhash)(?::[^\]]+)?]/i, getRelativePath = (root, resourcePath)=>{
3
4
  let relativePath = node_path.relative(root, resourcePath);
4
5
  if (relativePath && !('..' === relativePath || relativePath.startsWith(`..${node_path.sep}`)) && !node_path.isAbsolute(relativePath)) return relativePath.replace(/\\/g, '/');
5
6
  }, pitch = async function(remainingRequest) {
6
7
  let root, resourcePath, nameSource, hash, options = this.getOptions();
7
- if (((modules, resourcePath, resourceQuery, resourceFragment)=>{
8
- if (!modules) return !1;
9
- if (!0 === modules || 'string' == typeof modules) return !0;
10
- let { auto } = modules;
11
- return !1 !== auto && (auto instanceof RegExp ? auto.test(resourcePath) : 'function' == typeof auto ? auto(resourcePath, resourceQuery, resourceFragment) : CSS_MODULE_REGEX.test(resourcePath));
12
- })(options.modules, this.resourcePath, this.resourceQuery, this.resourceFragment)) throw Error('[rsbuild:css] CSS Modules do not support the ?url query. Use ?inline to import the compiled CSS content as a string.');
8
+ if (isCSSModules(options.modules, this)) throw Error('[rsbuild:css] CSS Modules do not support the ?url query. Use ?inline to import the compiled CSS content as a string.');
13
9
  let content = ((moduleExports)=>{
14
10
  let content = moduleExports && 'object' == typeof moduleExports && 'default' in moduleExports ? moduleExports.default : moduleExports;
15
11
  if ('string' != typeof content) throw Error('[rsbuild:css] Expected CSS ?url imports to export a string.');
@@ -1,3 +1,9 @@
1
+ import { isCSSModules } from "./349.js";
2
+ let pitch = function() {
3
+ let { modules } = this.getOptions();
4
+ if (!isCSSModules(modules, this)) return '';
5
+ };
1
6
  export default function(source) {
2
- return (this?.cacheable(!0), source.includes('___CSS_LOADER_EXPORT___')) ? '' : source;
7
+ return source.includes('___CSS_LOADER_EXPORT___') ? '' : source;
3
8
  };
9
+ export { pitch };