@rsbuild/core 2.0.14 → 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.14",
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);
@@ -8379,10 +8393,7 @@ function applyDefaultPlugins(pluginManager, context) {
8379
8393
  level: 'error'
8380
8394
  }), chain.watchOptions({
8381
8395
  aggregateTimeout: 0
8382
- }), chain.performance.hints(!1), chain.experiments({
8383
- ...chain.get('experiments'),
8384
- pureFunctions: !0
8385
- }), chain.module.parser.merge({
8396
+ }), chain.performance.hints(!1), chain.module.parser.merge({
8386
8397
  javascript: {
8387
8398
  typeReexportsPresence: 'tolerant'
8388
8399
  }
@@ -9062,7 +9073,9 @@ try {
9062
9073
  } : {
9063
9074
  ...cssLoaderOptions,
9064
9075
  importLoaders: importLoaders.normal
9065
- }, 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);
9066
9079
  });
9067
9080
  let cssUrlFilename = getFilename(config, 'css', isProd), cssUrlPath = config.output.distPath.css;
9068
9081
  urlRule.use(CHAIN_ID.USE.CSS_URL).options({
@@ -9992,7 +10005,7 @@ let applyServerOptions = (command)=>{
9992
10005
  };
9993
10006
  function setupCommands() {
9994
10007
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9995
- cli.version("2.0.14"), 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)', {
9996
10009
  default: 'auto'
9997
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', {
9998
10011
  type: [
@@ -10063,7 +10076,7 @@ function initNodeEnv(command) {
10063
10076
  }
10064
10077
  function showGreeting() {
10065
10078
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
10066
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.14\n`);
10079
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.15\n`);
10067
10080
  }
10068
10081
  function setupLogLevel() {
10069
10082
  if (cli_argv.length <= 3) return;
@@ -10085,5 +10098,5 @@ function runCLI() {
10085
10098
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
10086
10099
  }
10087
10100
  }
10088
- let src_version = "2.0.14";
10101
+ let src_version = "2.0.15";
10089
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 };