@rsbuild/core 1.1.0-beta.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/rsbuild.js CHANGED
@@ -1,9 +1,21 @@
1
1
  #!/usr/bin/env node
2
- import { __internalHelper, logger } from '../dist/index.js';
2
+ import nodeModule from 'node:module';
3
3
 
4
- const { runCli, prepareCli } = __internalHelper;
4
+ // enable on-disk code caching of all modules loaded by Node.js
5
+ // requires Nodejs >= 22.8.0
6
+ const { enableCompileCache } = nodeModule;
7
+ if (enableCompileCache) {
8
+ try {
9
+ enableCompileCache();
10
+ } catch {
11
+ // ignore errors
12
+ }
13
+ }
5
14
 
6
15
  async function main() {
16
+ const { __internalHelper, logger } = await import('../dist/index.js');
17
+ const { runCli, prepareCli } = __internalHelper;
18
+
7
19
  prepareCli();
8
20
 
9
21
  try {
@@ -84,17 +84,17 @@
84
84
  399: (module, __unused_webpack_exports, __nccwpck_require__) => {
85
85
  module.exports = __nccwpck_require__(351);
86
86
  },
87
- 155: (module, __unused_webpack_exports, __nccwpck_require__) => {
87
+ 761: (module, __unused_webpack_exports, __nccwpck_require__) => {
88
88
  "use strict";
89
- const stringify = __nccwpck_require__(333);
90
- const compile = __nccwpck_require__(429);
91
- const expand = __nccwpck_require__(992);
92
- const parse = __nccwpck_require__(661);
89
+ const stringify = __nccwpck_require__(455);
90
+ const compile = __nccwpck_require__(370);
91
+ const expand = __nccwpck_require__(652);
92
+ const parse = __nccwpck_require__(266);
93
93
  const braces = (input, options = {}) => {
94
94
  let output = [];
95
95
  if (Array.isArray(input)) {
96
- for (let pattern of input) {
97
- let result = braces.create(pattern, options);
96
+ for (const pattern of input) {
97
+ const result = braces.create(pattern, options);
98
98
  if (Array.isArray(result)) {
99
99
  output.push(...result);
100
100
  } else {
@@ -145,22 +145,23 @@
145
145
  };
146
146
  module.exports = braces;
147
147
  },
148
- 429: (module, __unused_webpack_exports, __nccwpck_require__) => {
148
+ 370: (module, __unused_webpack_exports, __nccwpck_require__) => {
149
149
  "use strict";
150
- const fill = __nccwpck_require__(793);
151
- const utils = __nccwpck_require__(354);
150
+ const fill = __nccwpck_require__(176);
151
+ const utils = __nccwpck_require__(342);
152
152
  const compile = (ast, options = {}) => {
153
- let walk = (node, parent = {}) => {
154
- let invalidBlock = utils.isInvalidBrace(parent);
155
- let invalidNode =
153
+ const walk = (node, parent = {}) => {
154
+ const invalidBlock = utils.isInvalidBrace(parent);
155
+ const invalidNode =
156
156
  node.invalid === true && options.escapeInvalid === true;
157
- let invalid = invalidBlock === true || invalidNode === true;
158
- let prefix = options.escapeInvalid === true ? "\\" : "";
157
+ const invalid = invalidBlock === true || invalidNode === true;
158
+ const prefix = options.escapeInvalid === true ? "\\" : "";
159
159
  let output = "";
160
160
  if (node.isOpen === true) {
161
161
  return prefix + node.value;
162
162
  }
163
163
  if (node.isClose === true) {
164
+ console.log("node.isClose", prefix, node.value);
164
165
  return prefix + node.value;
165
166
  }
166
167
  if (node.type === "open") {
@@ -176,18 +177,19 @@
176
177
  return node.value;
177
178
  }
178
179
  if (node.nodes && node.ranges > 0) {
179
- let args = utils.reduce(node.nodes);
180
- let range = fill(...args, {
180
+ const args = utils.reduce(node.nodes);
181
+ const range = fill(...args, {
181
182
  ...options,
182
183
  wrap: false,
183
184
  toRegex: true,
185
+ strictZeros: true,
184
186
  });
185
187
  if (range.length !== 0) {
186
188
  return args.length > 1 && range.length > 1 ? `(${range})` : range;
187
189
  }
188
190
  }
189
191
  if (node.nodes) {
190
- for (let child of node.nodes) {
192
+ for (const child of node.nodes) {
191
193
  output += walk(child, node);
192
194
  }
193
195
  }
@@ -197,10 +199,10 @@
197
199
  };
198
200
  module.exports = compile;
199
201
  },
200
- 307: (module) => {
202
+ 713: (module) => {
201
203
  "use strict";
202
204
  module.exports = {
203
- MAX_LENGTH: 1024 * 64,
205
+ MAX_LENGTH: 1e4,
204
206
  CHAR_0: "0",
205
207
  CHAR_9: "9",
206
208
  CHAR_UPPERCASE_A: "A",
@@ -247,13 +249,13 @@
247
249
  CHAR_ZERO_WIDTH_NOBREAK_SPACE: "\ufeff",
248
250
  };
249
251
  },
250
- 992: (module, __unused_webpack_exports, __nccwpck_require__) => {
252
+ 652: (module, __unused_webpack_exports, __nccwpck_require__) => {
251
253
  "use strict";
252
- const fill = __nccwpck_require__(793);
253
- const stringify = __nccwpck_require__(333);
254
- const utils = __nccwpck_require__(354);
254
+ const fill = __nccwpck_require__(176);
255
+ const stringify = __nccwpck_require__(455);
256
+ const utils = __nccwpck_require__(342);
255
257
  const append = (queue = "", stash = "", enclose = false) => {
256
- let result = [];
258
+ const result = [];
257
259
  queue = [].concat(queue);
258
260
  stash = [].concat(stash);
259
261
  if (!stash.length) return queue;
@@ -262,9 +264,9 @@
262
264
  ? utils.flatten(stash).map((ele) => `{${ele}}`)
263
265
  : stash;
264
266
  }
265
- for (let item of queue) {
267
+ for (const item of queue) {
266
268
  if (Array.isArray(item)) {
267
- for (let value of item) {
269
+ for (const value of item) {
268
270
  result.push(append(value, stash, enclose));
269
271
  }
270
272
  } else {
@@ -279,9 +281,9 @@
279
281
  return utils.flatten(result);
280
282
  };
281
283
  const expand = (ast, options = {}) => {
282
- let rangeLimit =
283
- options.rangeLimit === void 0 ? 1e3 : options.rangeLimit;
284
- let walk = (node, parent = {}) => {
284
+ const rangeLimit =
285
+ options.rangeLimit === undefined ? 1e3 : options.rangeLimit;
286
+ const walk = (node, parent = {}) => {
285
287
  node.queue = [];
286
288
  let p = parent;
287
289
  let q = parent.queue;
@@ -302,7 +304,7 @@
302
304
  return;
303
305
  }
304
306
  if (node.nodes && node.ranges > 0) {
305
- let args = utils.reduce(node.nodes);
307
+ const args = utils.reduce(node.nodes);
306
308
  if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
307
309
  throw new RangeError(
308
310
  "expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.",
@@ -316,7 +318,7 @@
316
318
  node.nodes = [];
317
319
  return;
318
320
  }
319
- let enclose = utils.encloseBrace(node);
321
+ const enclose = utils.encloseBrace(node);
320
322
  let queue = node.queue;
321
323
  let block = node;
322
324
  while (
@@ -328,7 +330,7 @@
328
330
  queue = block.queue;
329
331
  }
330
332
  for (let i = 0; i < node.nodes.length; i++) {
331
- let child = node.nodes[i];
333
+ const child = node.nodes[i];
332
334
  if (child.type === "comma" && node.type === "brace") {
333
335
  if (i === 1) queue.push("");
334
336
  queue.push("");
@@ -352,9 +354,9 @@
352
354
  };
353
355
  module.exports = expand;
354
356
  },
355
- 661: (module, __unused_webpack_exports, __nccwpck_require__) => {
357
+ 266: (module, __unused_webpack_exports, __nccwpck_require__) => {
356
358
  "use strict";
357
- const stringify = __nccwpck_require__(333);
359
+ const stringify = __nccwpck_require__(455);
358
360
  const {
359
361
  MAX_LENGTH,
360
362
  CHAR_BACKSLASH,
@@ -371,13 +373,13 @@
371
373
  CHAR_SINGLE_QUOTE,
372
374
  CHAR_NO_BREAK_SPACE,
373
375
  CHAR_ZERO_WIDTH_NOBREAK_SPACE,
374
- } = __nccwpck_require__(307);
376
+ } = __nccwpck_require__(713);
375
377
  const parse = (input, options = {}) => {
376
378
  if (typeof input !== "string") {
377
379
  throw new TypeError("Expected a string");
378
380
  }
379
- let opts = options || {};
380
- let max =
381
+ const opts = options || {};
382
+ const max =
381
383
  typeof opts.maxLength === "number"
382
384
  ? Math.min(MAX_LENGTH, opts.maxLength)
383
385
  : MAX_LENGTH;
@@ -386,16 +388,15 @@
386
388
  `Input length (${input.length}), exceeds max characters (${max})`,
387
389
  );
388
390
  }
389
- let ast = { type: "root", input, nodes: [] };
390
- let stack = [ast];
391
+ const ast = { type: "root", input, nodes: [] };
392
+ const stack = [ast];
391
393
  let block = ast;
392
394
  let prev = ast;
393
395
  let brackets = 0;
394
- let length = input.length;
396
+ const length = input.length;
395
397
  let index = 0;
396
398
  let depth = 0;
397
399
  let value;
398
- let memo = {};
399
400
  const advance = () => input[index++];
400
401
  const push = (node) => {
401
402
  if (node.type === "text" && prev.type === "dot") {
@@ -434,7 +435,6 @@
434
435
  }
435
436
  if (value === CHAR_LEFT_SQUARE_BRACKET) {
436
437
  brackets++;
437
- let closed = true;
438
438
  let next;
439
439
  while (index < length && (next = advance())) {
440
440
  value += next;
@@ -477,7 +477,7 @@
477
477
  value === CHAR_SINGLE_QUOTE ||
478
478
  value === CHAR_BACKTICK
479
479
  ) {
480
- let open = value;
480
+ const open = value;
481
481
  let next;
482
482
  if (options.keepQuotes !== true) {
483
483
  value = "";
@@ -498,10 +498,10 @@
498
498
  }
499
499
  if (value === CHAR_LEFT_CURLY_BRACE) {
500
500
  depth++;
501
- let dollar =
501
+ const dollar =
502
502
  (prev.value && prev.value.slice(-1) === "$") ||
503
503
  block.dollar === true;
504
- let brace = {
504
+ const brace = {
505
505
  type: "brace",
506
506
  open: true,
507
507
  close: false,
@@ -521,7 +521,7 @@
521
521
  push({ type: "text", value });
522
522
  continue;
523
523
  }
524
- let type = "close";
524
+ const type = "close";
525
525
  block = stack.pop();
526
526
  block.close = true;
527
527
  push({ type, value });
@@ -532,7 +532,7 @@
532
532
  if (value === CHAR_COMMA && depth > 0) {
533
533
  if (block.ranges > 0) {
534
534
  block.ranges = 0;
535
- let open = block.nodes.shift();
535
+ const open = block.nodes.shift();
536
536
  block.nodes = [open, { type: "text", value: stringify(block) }];
537
537
  }
538
538
  push({ type: "comma", value });
@@ -540,7 +540,7 @@
540
540
  continue;
541
541
  }
542
542
  if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
543
- let siblings = block.nodes;
543
+ const siblings = block.nodes;
544
544
  if (depth === 0 || siblings.length === 0) {
545
545
  push({ type: "text", value });
546
546
  continue;
@@ -561,7 +561,7 @@
561
561
  }
562
562
  if (prev.type === "range") {
563
563
  siblings.pop();
564
- let before = siblings[siblings.length - 1];
564
+ const before = siblings[siblings.length - 1];
565
565
  before.value += prev.value + value;
566
566
  prev = before;
567
567
  block.ranges--;
@@ -583,8 +583,8 @@
583
583
  node.invalid = true;
584
584
  }
585
585
  });
586
- let parent = stack[stack.length - 1];
587
- let index = parent.nodes.indexOf(block);
586
+ const parent = stack[stack.length - 1];
587
+ const index = parent.nodes.indexOf(block);
588
588
  parent.nodes.splice(index, 1, ...block.nodes);
589
589
  }
590
590
  } while (stack.length > 0);
@@ -593,14 +593,14 @@
593
593
  };
594
594
  module.exports = parse;
595
595
  },
596
- 333: (module, __unused_webpack_exports, __nccwpck_require__) => {
596
+ 455: (module, __unused_webpack_exports, __nccwpck_require__) => {
597
597
  "use strict";
598
- const utils = __nccwpck_require__(354);
598
+ const utils = __nccwpck_require__(342);
599
599
  module.exports = (ast, options = {}) => {
600
- let stringify = (node, parent = {}) => {
601
- let invalidBlock =
600
+ const stringify = (node, parent = {}) => {
601
+ const invalidBlock =
602
602
  options.escapeInvalid && utils.isInvalidBrace(parent);
603
- let invalidNode =
603
+ const invalidNode =
604
604
  node.invalid === true && options.escapeInvalid === true;
605
605
  let output = "";
606
606
  if (node.value) {
@@ -613,7 +613,7 @@
613
613
  return node.value;
614
614
  }
615
615
  if (node.nodes) {
616
- for (let child of node.nodes) {
616
+ for (const child of node.nodes) {
617
617
  output += stringify(child);
618
618
  }
619
619
  }
@@ -622,7 +622,7 @@
622
622
  return stringify(ast);
623
623
  };
624
624
  },
625
- 354: (__unused_webpack_module, exports) => {
625
+ 342: (__unused_webpack_module, exports) => {
626
626
  "use strict";
627
627
  exports.isInteger = (num) => {
628
628
  if (typeof num === "number") {
@@ -641,7 +641,7 @@
641
641
  return (Number(max) - Number(min)) / Number(step) >= limit;
642
642
  };
643
643
  exports.escapeNode = (block, n = 0, type) => {
644
- let node = block.nodes[n];
644
+ const node = block.nodes[n];
645
645
  if (!node) return;
646
646
  if (
647
647
  (type && node.type === type) ||
@@ -691,10 +691,14 @@
691
691
  const result = [];
692
692
  const flat = (arr) => {
693
693
  for (let i = 0; i < arr.length; i++) {
694
- let ele = arr[i];
695
- Array.isArray(ele)
696
- ? flat(ele, result)
697
- : ele !== void 0 && result.push(ele);
694
+ const ele = arr[i];
695
+ if (Array.isArray(ele)) {
696
+ flat(ele);
697
+ continue;
698
+ }
699
+ if (ele !== undefined) {
700
+ result.push(ele);
701
+ }
698
702
  }
699
703
  return result;
700
704
  };
@@ -1818,7 +1822,7 @@
1818
1822
  }
1819
1823
  module.exports = NodeFsHandler;
1820
1824
  },
1821
- 793: (module, __unused_webpack_exports, __nccwpck_require__) => {
1825
+ 176: (module, __unused_webpack_exports, __nccwpck_require__) => {
1822
1826
  "use strict";
1823
1827
  /*!
1824
1828
  * fill-range <https://github.com/jonschlinkert/fill-range>
@@ -1869,7 +1873,7 @@
1869
1873
  while (input.length < maxLength) input = "0" + input;
1870
1874
  return negative ? "-" + input : input;
1871
1875
  };
1872
- const toSequence = (parts, options) => {
1876
+ const toSequence = (parts, options, maxLen) => {
1873
1877
  parts.negatives.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
1874
1878
  parts.positives.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
1875
1879
  let prefix = options.capture ? "" : "?:";
@@ -1877,10 +1881,12 @@
1877
1881
  let negatives = "";
1878
1882
  let result;
1879
1883
  if (parts.positives.length) {
1880
- positives = parts.positives.join("|");
1884
+ positives = parts.positives
1885
+ .map((v) => toMaxLen(String(v), maxLen))
1886
+ .join("|");
1881
1887
  }
1882
1888
  if (parts.negatives.length) {
1883
- negatives = `-(${prefix}${parts.negatives.join("|")})`;
1889
+ negatives = `-(${prefix}${parts.negatives.map((v) => toMaxLen(String(v), maxLen)).join("|")})`;
1884
1890
  }
1885
1891
  if (positives && negatives) {
1886
1892
  result = `${positives}|${negatives}`;
@@ -1967,7 +1973,7 @@
1967
1973
  }
1968
1974
  if (options.toRegex === true) {
1969
1975
  return step > 1
1970
- ? toSequence(parts, options)
1976
+ ? toSequence(parts, options, maxLen)
1971
1977
  : toRegex(range, null, { wrap: false, ...options });
1972
1978
  }
1973
1979
  return range;
@@ -4422,7 +4428,7 @@
4422
4428
  const anymatch = __nccwpck_require__(139)["default"];
4423
4429
  const globParent = __nccwpck_require__(514);
4424
4430
  const isGlob = __nccwpck_require__(11);
4425
- const braces = __nccwpck_require__(155);
4431
+ const braces = __nccwpck_require__(761);
4426
4432
  const normalizePath = __nccwpck_require__(631);
4427
4433
  const NodeFsHandler = __nccwpck_require__(594);
4428
4434
  const FsEventsHandler = __nccwpck_require__(888);