@rslib/core 0.19.6 → 0.20.0-canary-202603091

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/800.js CHANGED
@@ -75,8 +75,8 @@ function isCssGlobalFile(filepath, auto) {
75
75
  const isCssModules = isCssModulesFile(filepath, auto);
76
76
  return !isCssModules;
77
77
  }
78
- const BASE_URI = 'webpack://';
79
- const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
80
- const ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
81
- const SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
78
+ const BASE_URI = 'rspack-css-extract://';
79
+ const AUTO_PUBLIC_PATH = '__css_extract_public_path_auto__';
80
+ const ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/css-extract-plugin/`;
81
+ const SINGLE_DOT_PATH_SEGMENT = '__css_extract_single_dot_path_segment__';
82
82
  export { ABSOLUTE_PUBLIC_PATH, AUTO_PUBLIC_PATH, BASE_URI, CSS_EXTENSIONS_PATTERN, DTS_EXTENSIONS_PATTERN, JS_EXTENSIONS_PATTERN, SINGLE_DOT_PATH_SEGMENT, SWC_HELPERS, basename, dirname, extname, getUndoPath, isAbsolute, isCssFile, isCssGlobalFile, isCssModulesFile, join, node_path };
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as __rspack_external__rsbuild_core_1b356efc from "@rsbuild/core";
2
2
  import { logger } from "../compiled/rslog/index.js";
3
3
  import picocolors from "../compiled/picocolors/index.js";
4
- import { EventEmitter } from "events";
5
4
  import node_fs, { promises } from "node:fs";
6
5
  import node_fs_promises from "node:fs/promises";
7
6
  import node_util from "node:util";
@@ -42,13 +41,13 @@ function toArr(any) {
42
41
  ];
43
42
  }
44
43
  function toVal(out, key, val, opts) {
45
- var x, old = out[key], nxt = ~opts.string.indexOf(key) ? null == val || true === val ? '' : String(val) : 'boolean' == typeof val ? val : ~opts.boolean.indexOf(key) ? 'false' === val ? false : 'true' === val || (out._.push((x = +val, 0 * x === 0) ? x : val), !!val) : (x = +val, 0 * x === 0) ? x : val;
44
+ var x, old = out[key], nxt = ~opts.string.indexOf(key) ? null == val || true === val ? "" : String(val) : "boolean" == typeof val ? val : ~opts.boolean.indexOf(key) ? "false" === val ? false : "true" === val || (out._.push((x = +val, 0 * x === 0) ? x : val), !!val) : (x = +val, 0 * x === 0) ? x : val;
46
45
  out[key] = null == old ? nxt : Array.isArray(old) ? old.concat(nxt) : [
47
46
  old,
48
47
  nxt
49
48
  ];
50
49
  }
51
- function mri2(args, opts) {
50
+ function lib_default(args, opts) {
52
51
  args = args || [];
53
52
  opts = opts || {};
54
53
  var k, arr, arg, name, val, out = {
@@ -84,26 +83,26 @@ function mri2(args, opts) {
84
83
  const keys = strict ? Object.keys(opts.alias) : [];
85
84
  for(i = 0; i < len; i++){
86
85
  arg = args[i];
87
- if ('--' === arg) {
86
+ if ("--" === arg) {
88
87
  out._ = out._.concat(args.slice(++i));
89
88
  break;
90
89
  }
91
90
  for(j = 0; j < arg.length && 45 === arg.charCodeAt(j); j++);
92
91
  if (0 === j) out._.push(arg);
93
- else if ('no-' === arg.substring(j, j + 3)) {
92
+ else if ("no-" === arg.substring(j, j + 3)) {
94
93
  name = arg.substring(j + 3);
95
94
  if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
96
95
  out[name] = false;
97
96
  } else {
98
97
  for(idx = j + 1; idx < arg.length && 61 !== arg.charCodeAt(idx); idx++);
99
98
  name = arg.substring(j, idx);
100
- val = arg.substring(++idx) || i + 1 === len || 45 === ('' + args[i + 1]).charCodeAt(0) || args[++i];
99
+ val = arg.substring(++idx) || i + 1 === len || 45 === ("" + args[i + 1]).charCodeAt(0) || args[++i];
101
100
  arr = 2 === j ? [
102
101
  name
103
102
  ] : name;
104
103
  for(idx = 0; idx < arr.length; idx++){
105
104
  name = arr[idx];
106
- if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
105
+ if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
107
106
  toVal(out, name, idx + 1 < arr.length || val, opts);
108
107
  }
109
108
  }
@@ -117,8 +116,10 @@ function mri2(args, opts) {
117
116
  }
118
117
  return out;
119
118
  }
120
- const removeBrackets = (v)=>v.replace(/[<[].+/, "").trim();
121
- const findAllBrackets = (v)=>{
119
+ function removeBrackets(v) {
120
+ return v.replace(/[<[].+/, "").trim();
121
+ }
122
+ function findAllBrackets(v) {
122
123
  const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
123
124
  const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
124
125
  const res = [];
@@ -140,8 +141,8 @@ const findAllBrackets = (v)=>{
140
141
  let squareMatch;
141
142
  while(squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v))res.push(parse(squareMatch));
142
143
  return res;
143
- };
144
- const getMriOptions = (options)=>{
144
+ }
145
+ function getMriOptions(options) {
145
146
  const result = {
146
147
  alias: {},
147
148
  boolean: []
@@ -149,53 +150,74 @@ const getMriOptions = (options)=>{
149
150
  for (const [index, option] of options.entries()){
150
151
  if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
151
152
  if (option.isBoolean) if (option.negated) {
152
- const hasStringTypeOption = options.some((o, i)=>i !== index && o.names.some((name)=>option.names.includes(name)) && "boolean" == typeof o.required);
153
- if (!hasStringTypeOption) result.boolean.push(option.names[0]);
153
+ if (!options.some((o, i)=>i !== index && o.names.some((name)=>option.names.includes(name)) && "boolean" == typeof o.required)) result.boolean.push(option.names[0]);
154
154
  } else result.boolean.push(option.names[0]);
155
155
  }
156
156
  return result;
157
- };
158
- const findLongest = (arr)=>arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0];
159
- const padRight = (str, length)=>str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
160
- const camelcase = (input)=>input.replace(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
161
- const setDotProp = (obj, keys, val)=>{
162
- let i = 0;
163
- let length = keys.length;
164
- let t = obj;
165
- let x;
166
- for(; i < length; ++i){
167
- x = t[keys[i]];
168
- t = t[keys[i]] = i === length - 1 ? val : null != x ? x : !~keys[i + 1].indexOf(".") && +keys[i + 1] > -1 ? [] : {};
157
+ }
158
+ function findLongest(arr) {
159
+ return arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0];
160
+ }
161
+ function padRight(str, length) {
162
+ return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
163
+ }
164
+ function camelcase(input) {
165
+ return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
166
+ }
167
+ function setDotProp(obj, keys, val) {
168
+ let current = obj;
169
+ for(let i = 0; i < keys.length; i++){
170
+ const key = keys[i];
171
+ if (i === keys.length - 1) {
172
+ current[key] = val;
173
+ return;
174
+ }
175
+ if (null == current[key]) {
176
+ const nextKeyIsArrayIndex = +keys[i + 1] > -1;
177
+ current[key] = nextKeyIsArrayIndex ? [] : {};
178
+ }
179
+ current = current[key];
169
180
  }
170
- };
171
- const setByType = (obj, transforms)=>{
181
+ }
182
+ function setByType(obj, transforms) {
172
183
  for (const key of Object.keys(transforms)){
173
184
  const transform = transforms[key];
174
185
  if (transform.shouldTransform) {
175
- obj[key] = Array.prototype.concat.call([], obj[key]);
186
+ obj[key] = [
187
+ obj[key]
188
+ ].flat();
176
189
  if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
177
190
  }
178
191
  }
179
- };
180
- const getFileName = (input)=>{
181
- const m = /([^\\\/]+)$/.exec(input);
192
+ }
193
+ function getFileName(input) {
194
+ const m = /([^\\/]+)$/.exec(input);
182
195
  return m ? m[1] : "";
183
- };
184
- const camelcaseOptionName = (name)=>name.split(".").map((v, i)=>0 === i ? camelcase(v) : v).join(".");
185
- class CACError extends Error {
196
+ }
197
+ function camelcaseOptionName(name) {
198
+ return name.split(".").map((v, i)=>0 === i ? camelcase(v) : v).join(".");
199
+ }
200
+ var CACError = class extends Error {
186
201
  constructor(message){
187
202
  super(message);
188
- this.name = this.constructor.name;
189
- if ("function" == typeof Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
190
- else this.stack = new Error(message).stack;
203
+ this.name = "CACError";
204
+ if ("function" != typeof Error.captureStackTrace) this.stack = new Error(message).stack;
191
205
  }
192
- }
193
- class Option {
206
+ };
207
+ var Option = class {
208
+ rawName;
209
+ description;
210
+ name;
211
+ names;
212
+ isBoolean;
213
+ required;
214
+ config;
215
+ negated;
194
216
  constructor(rawName, description, config){
195
217
  this.rawName = rawName;
196
218
  this.description = description;
197
219
  this.config = Object.assign({}, config);
198
- rawName = rawName.replace(/\.\*/g, "");
220
+ rawName = rawName.replaceAll(".*", "");
199
221
  this.negated = false;
200
222
  this.names = removeBrackets(rawName).split(",").map((v)=>{
201
223
  let name = v.trim().replace(/^-{1,2}/, "");
@@ -205,16 +227,36 @@ class Option {
205
227
  }
206
228
  return camelcaseOptionName(name);
207
229
  }).sort((a, b)=>a.length > b.length ? 1 : -1);
208
- this.name = this.names[this.names.length - 1];
230
+ this.name = this.names.at(-1);
209
231
  if (this.negated && null == this.config.default) this.config.default = true;
210
232
  if (rawName.includes("<")) this.required = true;
211
233
  else if (rawName.includes("[")) this.required = false;
212
234
  else this.isBoolean = true;
213
235
  }
214
- }
215
- const processArgs = process.argv;
216
- const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
217
- class Command {
236
+ };
237
+ let runtimeProcessArgs;
238
+ let runtimeInfo;
239
+ if ("u" > typeof process) {
240
+ let runtimeName;
241
+ runtimeName = "u" > typeof Deno && "string" == typeof Deno.version?.deno ? "deno" : "u" > typeof Bun && "string" == typeof Bun.version ? "bun" : "node";
242
+ runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
243
+ runtimeProcessArgs = process.argv;
244
+ } else runtimeInfo = "u" < typeof navigator ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
245
+ var Command = class {
246
+ rawName;
247
+ description;
248
+ config;
249
+ cli;
250
+ options;
251
+ aliasNames;
252
+ name;
253
+ args;
254
+ commandAction;
255
+ usageText;
256
+ versionNumber;
257
+ examples;
258
+ helpCallback;
259
+ globalCommand;
218
260
  constructor(rawName, description, config = {}, cli){
219
261
  this.rawName = rawName;
220
262
  this.description = description;
@@ -285,14 +327,12 @@ class Command {
285
327
  title: "Usage",
286
328
  body: ` $ ${name} ${this.usageText || this.rawName}`
287
329
  });
288
- const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
289
- if (showCommands) {
330
+ if ((this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0) {
290
331
  const longestCommandName = findLongest(commands.map((command)=>command.rawName));
291
332
  sections.push({
292
333
  title: "Commands",
293
334
  body: commands.map((command)=>` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`).join("\n")
294
- });
295
- sections.push({
335
+ }, {
296
336
  title: "For more info, run any command with the `--help` flag",
297
337
  body: commands.map((command)=>` $ ${name}${"" === command.name ? "" : ` ${command.name}`} --help`).join("\n")
298
338
  });
@@ -317,13 +357,12 @@ class Command {
317
357
  }).join("\n")
318
358
  });
319
359
  if (helpCallback) sections = helpCallback(sections) || sections;
320
- console.log(sections.map((section)=>section.title ? `${section.title}:
321
- ${section.body}` : section.body).join("\n\n"));
360
+ console.info(sections.map((section)=>section.title ? `${section.title}:\n${section.body}` : section.body).join("\n\n"));
322
361
  }
323
362
  outputVersion() {
324
363
  const { name } = this.cli;
325
364
  const { versionNumber } = this.cli.globalCommand;
326
- if (versionNumber) console.log(`${name}/${versionNumber} ${platformInfo}`);
365
+ if (versionNumber) console.info(`${name}/${versionNumber} ${runtimeInfo}`);
327
366
  }
328
367
  checkRequiredArgs() {
329
368
  const minimalArgsCount = this.args.filter((arg)=>arg.required).length;
@@ -349,14 +388,27 @@ ${section.body}` : section.body).join("\n\n"));
349
388
  }
350
389
  }
351
390
  }
352
- }
353
- class GlobalCommand extends Command {
391
+ checkUnusedArgs() {
392
+ const maximumArgsCount = this.args.some((arg)=>arg.variadic) ? 1 / 0 : this.args.length;
393
+ if (maximumArgsCount < this.cli.args.length) throw new CACError(`Unused args: ${this.cli.args.slice(maximumArgsCount).map((arg)=>`\`${arg}\``).join(", ")}`);
394
+ }
395
+ };
396
+ var GlobalCommand = class extends Command {
354
397
  constructor(cli){
355
398
  super("@@global@@", "", {}, cli);
356
399
  }
357
- }
358
- var __assign = Object.assign;
359
- class CAC extends EventEmitter {
400
+ };
401
+ var CAC = class extends EventTarget {
402
+ name;
403
+ commands;
404
+ globalCommand;
405
+ matchedCommand;
406
+ matchedCommandName;
407
+ rawArgs;
408
+ args;
409
+ options;
410
+ showHelpOnExit;
411
+ showVersionOnExit;
360
412
  constructor(name = ""){
361
413
  super();
362
414
  this.name = name;
@@ -414,7 +466,11 @@ class CAC extends EventEmitter {
414
466
  this.matchedCommand = void 0;
415
467
  this.matchedCommandName = void 0;
416
468
  }
417
- parse(argv = processArgs, { run = true } = {}) {
469
+ parse(argv, { run = true } = {}) {
470
+ if (!argv) {
471
+ if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
472
+ argv = runtimeProcessArgs;
473
+ }
418
474
  this.rawArgs = argv;
419
475
  if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
420
476
  let shouldParse = true;
@@ -423,19 +479,24 @@ class CAC extends EventEmitter {
423
479
  const commandName = parsed.args[0];
424
480
  if (command.isMatched(commandName)) {
425
481
  shouldParse = false;
426
- const parsedInfo = __assign(__assign({}, parsed), {
482
+ const parsedInfo = {
483
+ ...parsed,
427
484
  args: parsed.args.slice(1)
428
- });
485
+ };
429
486
  this.setParsedInfo(parsedInfo, command, commandName);
430
- this.emit(`command:${commandName}`, command);
487
+ this.dispatchEvent(new CustomEvent(`command:${commandName}`, {
488
+ detail: command
489
+ }));
431
490
  }
432
491
  }
433
492
  if (shouldParse) {
434
- for (const command of this.commands)if ("" === command.name) {
493
+ for (const command of this.commands)if (command.isDefaultCommand) {
435
494
  shouldParse = false;
436
495
  const parsed = this.mri(argv.slice(2), command);
437
496
  this.setParsedInfo(parsed, command);
438
- this.emit("command:!", command);
497
+ this.dispatchEvent(new CustomEvent("command:!", {
498
+ detail: command
499
+ }));
439
500
  }
440
501
  }
441
502
  if (shouldParse) {
@@ -457,7 +518,9 @@ class CAC extends EventEmitter {
457
518
  options: this.options
458
519
  };
459
520
  if (run) this.runMatchedCommand();
460
- if (!this.matchedCommand && this.args[0]) this.emit("command:*");
521
+ if (!this.matchedCommand && this.args[0]) this.dispatchEvent(new CustomEvent("command:*", {
522
+ detail: this.args[0]
523
+ }));
461
524
  return parsedArgv;
462
525
  }
463
526
  mri(argv, command) {
@@ -468,12 +531,13 @@ class CAC extends EventEmitter {
468
531
  const mriOptions = getMriOptions(cliOptions);
469
532
  let argsAfterDoubleDashes = [];
470
533
  const doubleDashesIndex = argv.indexOf("--");
471
- if (doubleDashesIndex > -1) {
534
+ if (-1 !== doubleDashesIndex) {
472
535
  argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
473
536
  argv = argv.slice(0, doubleDashesIndex);
474
537
  }
475
- let parsed = mri2(argv, mriOptions);
476
- parsed = Object.keys(parsed).reduce((res, name)=>__assign(__assign({}, res), {
538
+ let parsed = lib_default(argv, mriOptions);
539
+ parsed = Object.keys(parsed).reduce((res, name)=>({
540
+ ...res,
477
541
  [camelcaseOptionName(name)]: parsed[name]
478
542
  }), {
479
543
  _: []
@@ -483,20 +547,17 @@ class CAC extends EventEmitter {
483
547
  "--": argsAfterDoubleDashes
484
548
  };
485
549
  const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
486
- let transforms = Object.create(null);
550
+ const transforms = Object.create(null);
487
551
  for (const cliOption of cliOptions){
488
552
  if (!ignoreDefault && void 0 !== cliOption.config.default) for (const name of cliOption.names)options[name] = cliOption.config.default;
489
- if (Array.isArray(cliOption.config.type)) {
490
- if (void 0 === transforms[cliOption.name]) {
491
- transforms[cliOption.name] = Object.create(null);
492
- transforms[cliOption.name]["shouldTransform"] = true;
493
- transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
494
- }
553
+ if (Array.isArray(cliOption.config.type) && void 0 === transforms[cliOption.name]) {
554
+ transforms[cliOption.name] = Object.create(null);
555
+ transforms[cliOption.name].shouldTransform = true;
556
+ transforms[cliOption.name].transformFunction = cliOption.config.type[0];
495
557
  }
496
558
  }
497
559
  for (const key of Object.keys(parsed))if ("_" !== key) {
498
- const keys = key.split(".");
499
- setDotProp(options, keys, parsed[key]);
560
+ setDotProp(options, key.split("."), parsed[key]);
500
561
  setByType(options, transforms);
501
562
  }
502
563
  return {
@@ -510,6 +571,7 @@ class CAC extends EventEmitter {
510
571
  command.checkUnknownOptions();
511
572
  command.checkOptionValue();
512
573
  command.checkRequiredArgs();
574
+ command.checkUnusedArgs();
513
575
  const actionArgs = [];
514
576
  command.args.forEach((arg, index)=>{
515
577
  if (arg.variadic) actionArgs.push(args.slice(index));
@@ -518,9 +580,8 @@ class CAC extends EventEmitter {
518
580
  actionArgs.push(options);
519
581
  return command.commandAction.apply(this, actionArgs);
520
582
  }
521
- }
583
+ };
522
584
  const cac = (name = "")=>new CAC(name);
523
- const dist = cac;
524
585
  const nodeBuiltInModules = [
525
586
  'assert',
526
587
  'assert/strict',
@@ -918,22 +979,36 @@ const pluginLibCss = (rootDir, auto, banner, footer)=>({
918
979
  });
919
980
  api.modifyBundlerChain((config, { CHAIN_ID })=>{
920
981
  let isUsingCssExtract = false;
921
- for (const ruleId of [
922
- CHAIN_ID.RULE.CSS,
923
- CHAIN_ID.RULE.SASS,
924
- CHAIN_ID.RULE.LESS,
925
- CHAIN_ID.RULE.STYLUS
982
+ for (const [ruleId, oneOfId] of [
983
+ [
984
+ CHAIN_ID.RULE.CSS,
985
+ CHAIN_ID.ONE_OF.CSS_MAIN
986
+ ],
987
+ [
988
+ CHAIN_ID.RULE.SASS,
989
+ 'sass'
990
+ ],
991
+ [
992
+ CHAIN_ID.RULE.LESS,
993
+ 'less'
994
+ ],
995
+ [
996
+ CHAIN_ID.RULE.STYLUS,
997
+ 'stylus'
998
+ ]
926
999
  ]){
927
1000
  if (!config.module.rules.has(ruleId)) continue;
928
- const rule = config.module.rule(ruleId);
929
- if (rule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT)) {
930
- isUsingCssExtract = true;
931
- rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(cssConfig_require.resolve('./libCssExtractLoader.js')).options({
932
- rootDir,
933
- auto,
934
- banner,
935
- footer
936
- });
1001
+ const mainRule = config.module.rule(ruleId).oneOfs.get(oneOfId);
1002
+ if (mainRule) {
1003
+ if (mainRule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT)) {
1004
+ isUsingCssExtract = true;
1005
+ mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(cssConfig_require.resolve('./libCssExtractLoader.js')).options({
1006
+ rootDir,
1007
+ auto,
1008
+ banner,
1009
+ footer
1010
+ });
1011
+ }
937
1012
  }
938
1013
  }
939
1014
  if (isUsingCssExtract) {
@@ -957,9 +1032,7 @@ const composeCssConfig = (rootDir, auto, bundle = true, banner, footer)=>{
957
1032
  }
958
1033
  };
959
1034
  };
960
- const EntryChunkPlugin_require = createRequire(import.meta.url);
961
1035
  const EntryChunkPlugin_PLUGIN_NAME = 'rsbuild:lib-entry-chunk';
962
- const LOADER_NAME = 'rsbuild:lib-entry-module';
963
1036
  const IMPORT_META_URL_SHIM = `const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
964
1037
  return typeof document === 'undefined'
965
1038
  ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
@@ -1006,18 +1079,7 @@ class EntryChunkPlugin {
1006
1079
  });
1007
1080
  }
1008
1081
  }
1009
- const entryModuleLoaderRsbuildPlugin = ()=>({
1010
- name: EntryChunkPlugin_PLUGIN_NAME,
1011
- setup (api) {
1012
- api.modifyBundlerChain((config, { CHAIN_ID })=>{
1013
- config.module.rule(`Rslib:${CHAIN_ID.RULE.JS}-entry-loader`).test(config.module.rule(CHAIN_ID.RULE.JS).get('test')).issuer(/^$/).use(LOADER_NAME).loader(EntryChunkPlugin_require.resolve('./entryModuleLoader.js'));
1014
- });
1015
- }
1016
- });
1017
- const composeEntryChunkConfig = ({ enabledImportMetaUrlShim, useLoader, contextToWatch = null })=>({
1018
- plugins: useLoader ? [
1019
- entryModuleLoaderRsbuildPlugin()
1020
- ] : [],
1082
+ const composeEntryChunkConfig = ({ enabledImportMetaUrlShim, contextToWatch = null })=>({
1021
1083
  tools: {
1022
1084
  rspack: {
1023
1085
  plugins: [
@@ -1978,13 +2040,6 @@ async function createConstantRsbuildConfig() {
1978
2040
  moduleIds: 'named',
1979
2041
  nodeEnv: false
1980
2042
  },
1981
- experiments: {
1982
- rspackFuture: {
1983
- bundlerInfo: {
1984
- force: false
1985
- }
1986
- }
1987
- },
1988
2043
  resolve: {
1989
2044
  extensionAlias: {
1990
2045
  '.js': [
@@ -2020,7 +2075,7 @@ async function createConstantRsbuildConfig() {
2020
2075
  }
2021
2076
  });
2022
2077
  }
2023
- const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledShims, advancedEsm })=>{
2078
+ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledShims })=>{
2024
2079
  const jsParserOptions = {
2025
2080
  cjs: {
2026
2081
  requireResolve: false,
@@ -2038,13 +2093,11 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
2038
2093
  worker: false
2039
2094
  }
2040
2095
  };
2041
- const experimentalEsmOutput = bundle && 'esm' === format && advancedEsm;
2042
2096
  const plugins = [
2043
2097
  new __rspack_external__rsbuild_core_1b356efc.rspack.experiments.RslibPlugin({
2044
2098
  interceptApiPlugin: true,
2045
2099
  forceNodeShims: enabledShims.esm.__dirname || enabledShims.esm.__filename
2046
- }),
2047
- experimentalEsmOutput && new __rspack_external__rsbuild_core_1b356efc.rspack.experiments.EsmLibraryPlugin()
2100
+ })
2048
2101
  ].filter(Boolean);
2049
2102
  switch(format){
2050
2103
  case 'esm':
@@ -2064,11 +2117,11 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
2064
2117
  }
2065
2118
  },
2066
2119
  optimization: {
2067
- concatenateModules: !experimentalEsmOutput,
2068
- sideEffects: experimentalEsmOutput ? true : 'flag',
2069
- runtimeChunk: experimentalEsmOutput ? {
2120
+ concatenateModules: false,
2121
+ sideEffects: true,
2122
+ runtimeChunk: {
2070
2123
  name: 'rslib-runtime'
2071
- } : void 0,
2124
+ },
2072
2125
  avoidEntryIife: true,
2073
2126
  splitChunks: {
2074
2127
  chunks: 'async'
@@ -2076,16 +2129,13 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
2076
2129
  },
2077
2130
  output: {
2078
2131
  module: true,
2079
- chunkFormat: experimentalEsmOutput ? false : 'module',
2132
+ chunkFormat: false,
2080
2133
  library: {
2081
2134
  type: 'modern-module'
2082
2135
  },
2083
2136
  chunkLoading: 'import',
2084
2137
  workerChunkLoading: 'import'
2085
2138
  },
2086
- experiments: {
2087
- outputModule: true
2088
- },
2089
2139
  plugins
2090
2140
  }
2091
2141
  }
@@ -2093,6 +2143,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
2093
2143
  case 'cjs':
2094
2144
  return {
2095
2145
  output: {
2146
+ module: false,
2096
2147
  filenameHash: false
2097
2148
  },
2098
2149
  tools: {
@@ -2129,6 +2180,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
2129
2180
  if (!bundle) throw new Error('When using "umd" format, "bundle" must be set to "true". Since the default value for "bundle" is "true", so you can either explicitly set it to "true" or remove the field entirely.');
2130
2181
  const config = {
2131
2182
  output: {
2183
+ module: false,
2132
2184
  filenameHash: false
2133
2185
  },
2134
2186
  tools: {
@@ -2164,6 +2216,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
2164
2216
  if (!bundle) throw new Error('When using "iife" format, "bundle" must be set to "true". Since the default value for "bundle" is "true", so you can either explicitly set it to "true" or remove the field entirely.');
2165
2217
  const config = {
2166
2218
  output: {
2219
+ module: false,
2167
2220
  filenameHash: false,
2168
2221
  minify: {
2169
2222
  jsOptions: {
@@ -2186,7 +2239,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
2186
2239
  iife: true,
2187
2240
  asyncChunks: false,
2188
2241
  library: {
2189
- type: 'modern-module'
2242
+ type: 'module'
2190
2243
  }
2191
2244
  },
2192
2245
  optimization: {
@@ -2230,7 +2283,7 @@ const disableUrlParseRsbuildPlugin = ()=>({
2230
2283
  name: 'rsbuild:disable-url-parse',
2231
2284
  setup (api) {
2232
2285
  api.modifyBundlerChain((config, { CHAIN_ID })=>{
2233
- config.module.rule(CHAIN_ID.RULE.JS).parser({
2286
+ config.module.rule(CHAIN_ID.RULE.JS).oneOf(CHAIN_ID.ONE_OF.JS_MAIN).parser({
2234
2287
  url: false
2235
2288
  });
2236
2289
  });
@@ -2240,21 +2293,19 @@ const fixJsModuleTypePlugin = ()=>({
2240
2293
  name: 'rsbuild:fix-js-module-type',
2241
2294
  setup (api) {
2242
2295
  api.modifyBundlerChain((config, { CHAIN_ID })=>{
2243
- config.module.rule(CHAIN_ID.RULE.JS).delete('type');
2296
+ config.module.rule(CHAIN_ID.RULE.JS).oneOf(CHAIN_ID.ONE_OF.JS_MAIN).delete('type');
2244
2297
  });
2245
2298
  }
2246
2299
  });
2247
2300
  const BundlePlugin = ()=>({
2248
2301
  name: 'rslib:bundle',
2249
2302
  setup (api) {
2250
- api.onBeforeBuild({
2303
+ api.onBeforeEnvironmentCompile({
2251
2304
  order: 'post',
2252
- handler: ({ bundlerConfigs })=>{
2253
- if (bundlerConfigs) {
2254
- for (const config of bundlerConfigs)if (config?.module?.parser?.javascript?.jsx === true) {
2255
- logger.error('Bundle mode does not support preserving JSX syntax. Set "bundle" to "false" or change the JSX runtime to `automatic` or `classic`. Check out ' + picocolors.green('https://rslib.rs/guide/solution/react#jsx-transform') + ' for more details.');
2256
- process.exit(1);
2257
- }
2305
+ handler: ({ bundlerConfig })=>{
2306
+ if (bundlerConfig?.module?.parser?.javascript?.jsx === true) {
2307
+ logger.error('Bundle mode does not support preserving JSX syntax. Set "bundle" to "false" or change the JSX runtime to `automatic` or `classic`. Check out ' + picocolors.green('https://rslib.rs/guide/solution/react#jsx-transform') + ' for more details.');
2308
+ process.exit(1);
2258
2309
  }
2259
2310
  }
2260
2311
  });
@@ -2393,7 +2444,7 @@ const composeOutputFilenameConfig = (config, format, autoExtension, multiCompile
2393
2444
  const filenameHash = config.output?.filenameHash ?? false;
2394
2445
  const getHash = ()=>{
2395
2446
  if ('string' == typeof filenameHash) return filenameHash ? `.[${filenameHash}]` : '';
2396
- return filenameHash ? '.[contenthash:8]' : '';
2447
+ return filenameHash ? '.[contenthash:10]' : '';
2397
2448
  };
2398
2449
  const inferChunkFilename = (filename)=>{
2399
2450
  if ('function' != typeof filename) {
@@ -2492,8 +2543,11 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
2492
2543
  if (node_fs.existsSync(entryAbsPath)) {
2493
2544
  const stats = node_fs.statSync(entryAbsPath);
2494
2545
  if (!stats.isFile()) entryErrorReasons.push(dirError);
2495
- } else if (isDirLike) entryErrorReasons.push(dirError);
2496
- else entryErrorReasons.push(`Can't resolve the entry ${picocolors.cyan(`"${entry}"`)} at the location ${picocolors.cyan(entryAbsPath)}. Please ensure that the file exists.`);
2546
+ } else {
2547
+ const isGlobLike = entry.startsWith('!') || /[*?[{\]}]/.test(entry);
2548
+ if (isDirLike || isGlobLike) entryErrorReasons.push(dirError);
2549
+ else entryErrorReasons.push(`Can't resolve the entry ${picocolors.cyan(`"${entry}"`)} at the location ${picocolors.cyan(entryAbsPath)}. Please ensure that the file exists.`);
2550
+ }
2497
2551
  return entry;
2498
2552
  });
2499
2553
  if (entryErrorReasons.length) throw new AggregateError(entryErrorReasons.map((reason)=>new Error(reason)));
@@ -2759,8 +2813,7 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root = proces
2759
2813
  const pkgJson = readPackageJson(root);
2760
2814
  const { compilerOptions } = await loadTsconfig(root, config.source?.tsconfigPath);
2761
2815
  const cssModulesAuto = config.output?.cssModules?.auto ?? true;
2762
- const { format = 'esm', shims, bundle = true, banner = {}, footer = {}, autoExtension = true, autoExternal, externalHelpers = false, redirect = {}, umdName, experiments } = config;
2763
- const advancedEsm = experiments?.advancedEsm ?? true;
2816
+ const { format = 'esm', shims, bundle = true, banner = {}, footer = {}, autoExtension = true, autoExternal, externalHelpers = false, redirect = {}, umdName } = config;
2764
2817
  const { rsbuildConfig: bundleConfig } = composeBundleConfig(bundle);
2765
2818
  const { rsbuildConfig: shimsConfig, enabledShims } = composeShimsConfig(format, shims);
2766
2819
  const formatConfig = composeFormatConfig({
@@ -2768,8 +2821,7 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root = proces
2768
2821
  pkgJson: pkgJson,
2769
2822
  bundle,
2770
2823
  umdName,
2771
- enabledShims,
2772
- advancedEsm
2824
+ enabledShims
2773
2825
  });
2774
2826
  const externalHelpersConfig = composeExternalHelpersConfig(externalHelpers, pkgJson);
2775
2827
  const userExternalsConfig = composeExternalsConfig(format, config.output?.externals);
@@ -2788,7 +2840,6 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root = proces
2788
2840
  const cssConfig = composeCssConfig(outBase, cssModulesAuto, config.bundle, banner?.css, footer?.css);
2789
2841
  const assetConfig = composeAssetConfig(bundle, format);
2790
2842
  const entryChunkConfig = composeEntryChunkConfig({
2791
- useLoader: 'iife' === format || 'esm' === format && !advancedEsm,
2792
2843
  enabledImportMetaUrlShim: enabledShims.cjs['import.meta.url'],
2793
2844
  contextToWatch: outBase
2794
2845
  });
@@ -3180,8 +3231,8 @@ const applyCommonOptions = (cli)=>{
3180
3231
  }).option('--no-env', 'Disable loading of `.env` files');
3181
3232
  };
3182
3233
  function setupCommands() {
3183
- const cli = dist('rslib');
3184
- cli.version("0.19.6");
3234
+ const cli = cac('rslib');
3235
+ cli.version("0.20.0-canary-202603091");
3185
3236
  applyCommonOptions(cli);
3186
3237
  const buildDescription = `build the library for production ${picocolors.dim('(default if no command is given)')}`;
3187
3238
  const buildCommand = cli.command('', buildDescription).alias('build');
@@ -3281,7 +3332,7 @@ function showGreeting() {
3281
3332
  const isBun = npm_execpath?.includes('.bun');
3282
3333
  const isNodeRun = Boolean(NODE_RUN_SCRIPT_NAME);
3283
3334
  const prefix = isNpx || isBun || isNodeRun ? '\n' : '';
3284
- logger.greet(`${prefix}Rslib v0.19.6\n`);
3335
+ logger.greet(`${prefix}Rslib v0.20.0-canary-202603091\n`);
3285
3336
  }
3286
3337
  function setupLogLevel() {
3287
3338
  const logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -3335,7 +3386,7 @@ function mergeRslibConfig(...originalConfigs) {
3335
3386
  if (void 0 !== mergedLib) mergedConfig.lib = mergedLib;
3336
3387
  return mergedConfig;
3337
3388
  }
3338
- const src_version = "0.19.6";
3389
+ const src_version = "0.20.0-canary-202603091";
3339
3390
  var loadEnv = __rspack_external__rsbuild_core_1b356efc.loadEnv;
3340
3391
  var rspack = __rspack_external__rsbuild_core_1b356efc.rspack;
3341
3392
  export { __rspack_external__rsbuild_core_1b356efc as rsbuild, createRslib, defineConfig, loadConfig, loadEnv, mergeRslibConfig, rspack, runCLI, src_version as version };
@@ -4,11 +4,11 @@ function stringifyLocal(value) {
4
4
  return 'function' == typeof value ? value.toString() : JSON.stringify(value);
5
5
  }
6
6
  const libCssExtractLoader_loader = function(content) {
7
- if (this._compiler?.options?.experiments?.css && this._module && ('css' === this._module.type || 'css/auto' === this._module.type || 'css/global' === this._module.type || 'css/module' === this._module.type)) return content;
7
+ if (this._module && ('css' === this._module.type || 'css/auto' === this._module.type || 'css/global' === this._module.type || 'css/module' === this._module.type)) return content;
8
8
  };
9
9
  const pitch = function(request, _, _data) {
10
- if (this._compiler?.options?.experiments?.css && this._module && ('css' === this._module.type || 'css/auto' === this._module.type || 'css/global' === this._module.type || 'css/module' === this._module.type)) {
11
- const e = new Error("use type 'css' and `CssExtractRspackPlugin` together, please set `experiments.css` to `false` or set `{ type: \"javascript/auto\" }` for rules with `CssExtractRspackPlugin` in your rspack config (now `CssExtractRspackPlugin` does nothing).");
10
+ if (this._module && ('css' === this._module.type || 'css/auto' === this._module.type || 'css/global' === this._module.type || 'css/module' === this._module.type)) {
11
+ const e = new Error("use type 'css' and `CssExtractRspackPlugin` together, please set `{ type: \"javascript/auto\" }` for rules with `CssExtractRspackPlugin` in your rspack config (now `CssExtractRspackPlugin` does nothing).");
12
12
  e.stack = void 0;
13
13
  this.emitWarning(e);
14
14
  return;
@@ -1,5 +1,4 @@
1
- export declare const BASE_URI = "webpack://";
2
- export declare const MODULE_TYPE = "css/mini-extract";
3
- export declare const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
1
+ export declare const BASE_URI = "rspack-css-extract://";
2
+ export declare const AUTO_PUBLIC_PATH = "__css_extract_public_path_auto__";
4
3
  export declare const ABSOLUTE_PUBLIC_PATH: string;
5
- export declare const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
4
+ export declare const SINGLE_DOT_PATH_SEGMENT = "__css_extract_single_dot_path_segment__";
@@ -6,7 +6,7 @@ export { runCLI } from './cli';
6
6
  export { createRslib } from './createRslib';
7
7
  export { type ConfigParams, defineConfig, type LoadConfigOptions, type LoadConfigResult, type LoadEnvOptions, type LoadEnvResult, loadConfig, loadEnv, } from './loadConfig';
8
8
  export { mergeRslibConfig } from './mergeConfig';
9
- export type { AutoExternal, BannerAndFooter, BuildOptions, BuildResult, CreateRslibOptions, Dts, Format, InspectConfigOptions, InspectConfigResult, LibConfig, LibExperiments, OnAfterCreateRsbuildFn, Redirect, RslibConfig, RslibInstance, Shims, StartMFDevServerOptions, StartServerResult, Syntax, } from './types';
9
+ export type { AutoExternal, BannerAndFooter, BuildOptions, BuildResult, CreateRslibOptions, Dts, Format, InspectConfigOptions, InspectConfigResult, LibConfig, LibExperiments, OnAfterCreateRsbuildFn, Redirect, RslibConfig, RslibInstance, Shims, StartMFDevServerOptions, StartDevServerResult, Syntax, } from './types';
10
10
  export declare const version: string;
11
11
  export type * as Rsbuild from '@rsbuild/core';
12
12
  export * as rsbuild from '@rsbuild/core';
@@ -1,6 +1,5 @@
1
1
  import { type EnvironmentConfig } from '@rsbuild/core';
2
- export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, useLoader, contextToWatch, }: {
3
- useLoader: boolean;
2
+ export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, contextToWatch, }: {
4
3
  enabledImportMetaUrlShim: boolean;
5
4
  contextToWatch: string | null;
6
5
  }) => EnvironmentConfig;
@@ -208,6 +208,7 @@ export type Redirect = {
208
208
  export type LibExperiments = {
209
209
  /**
210
210
  * Whether to enable Rspack advanced ESM output.
211
+ * @deprecated The advanced ESM output is now the default output for ESM format and this option has no effect. It will be removed in a future major version.
211
212
  * @defaultValue `true`
212
213
  * @see {@link https://rslib.rs/config/lib/experiments#experimentsadvancedesm}
213
214
  */
@@ -1,4 +1,4 @@
1
- import type { BuildResult, LoadEnvOptions, InspectConfigResult as RsbuildInspectConfigResult, RsbuildInstance, RsbuildMode, StartServerResult } from '@rsbuild/core';
1
+ import type { BuildResult, LoadEnvOptions, InspectConfigResult as RsbuildInspectConfigResult, RsbuildInstance, RsbuildMode, StartDevServerResult } from '@rsbuild/core';
2
2
  import type { RslibConfig } from './config';
3
3
  export type CommonOptions = {
4
4
  /**
@@ -38,7 +38,7 @@ export type InspectConfigOptions = CommonOptions & {
38
38
  writeToDisk?: boolean;
39
39
  };
40
40
  export type StartMFDevServerOptions = CommonOptions;
41
- export type { BuildResult, StartServerResult };
41
+ export type { BuildResult, StartDevServerResult };
42
42
  export type InspectConfigResult = {
43
43
  rslibConfig: string;
44
44
  } & RsbuildInspectConfigResult;
@@ -74,7 +74,7 @@ export type RslibInstance = {
74
74
  * 1. Start a development server that serves your mf format module.
75
75
  * 2. Watch for file changes and trigger recompilation.
76
76
  */
77
- startMFDevServer(options?: StartMFDevServerOptions): Promise<StartServerResult>;
77
+ startMFDevServer(options?: StartMFDevServerOptions): Promise<StartDevServerResult>;
78
78
  };
79
79
  export type OnAfterCreateRsbuildFn = (params: {
80
80
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.19.6",
3
+ "version": "0.20.0-canary-202603091",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://rslib.rs",
6
6
  "bugs": {
@@ -36,21 +36,21 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rsbuild/core": "~1.7.3",
40
- "rsbuild-plugin-dts": "0.19.6"
39
+ "@rsbuild/core": "2.0.0-beta.7",
40
+ "rsbuild-plugin-dts": "0.20.0-canary-202603091"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@module-federation/rsbuild-plugin": "^0.24.1",
44
44
  "@types/fs-extra": "^11.0.4",
45
- "cac": "^6.7.14",
45
+ "cac": "^7.0.0",
46
46
  "chokidar": "^4.0.3",
47
- "fs-extra": "^11.3.3",
48
- "memfs": "^4.56.10",
47
+ "fs-extra": "^11.3.4",
48
+ "memfs": "^4.56.11",
49
49
  "path-serializer": "0.5.1",
50
50
  "picocolors": "1.1.1",
51
51
  "prebundle": "1.6.2",
52
52
  "rsbuild-plugin-publint": "^0.3.4",
53
- "rslib": "npm:@rslib/core@0.19.5",
53
+ "rslib": "npm:@rslib/core@0.19.6",
54
54
  "rslog": "^1.3.2",
55
55
  "tinyglobby": "0.2.14",
56
56
  "tsconfck": "3.1.6",
@@ -70,7 +70,7 @@
70
70
  }
71
71
  },
72
72
  "engines": {
73
- "node": ">=18.12.0"
73
+ "node": "^20.19.0 || >=22.12.0"
74
74
  },
75
75
  "publishConfig": {
76
76
  "access": "public",
@@ -1,5 +0,0 @@
1
- const entryModuleLoader_loader = function(source) {
2
- return source;
3
- };
4
- const entryModuleLoader = entryModuleLoader_loader;
5
- export default entryModuleLoader;
@@ -1,3 +0,0 @@
1
- import type { Rspack } from '@rsbuild/core';
2
- declare const loader: Rspack.LoaderDefinition;
3
- export default loader;