@rsbuild/core 1.2.11 → 1.2.13

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.
Files changed (40) hide show
  1. package/compiled/chokidar/index.d.ts +61 -23
  2. package/compiled/chokidar/index.js +71 -56
  3. package/compiled/css-loader/index.js +309 -195
  4. package/compiled/html-rspack-plugin/index.js +14 -14
  5. package/compiled/http-proxy-middleware/index.d.ts +1 -1
  6. package/compiled/launch-editor-middleware/index.js +9 -6
  7. package/compiled/mrmime/index.js +4 -0
  8. package/compiled/mrmime/package.json +1 -1
  9. package/compiled/postcss/index.js +194 -194
  10. package/compiled/postcss/package.json +1 -1
  11. package/compiled/postcss-load-config/index.js +11 -11
  12. package/compiled/postcss-loader/index.js +9 -9
  13. package/compiled/rsbuild-dev-middleware/index.js +56 -46
  14. package/compiled/rsbuild-dev-middleware/package.json +1 -1
  15. package/compiled/rspack-manifest-plugin/index.js +4 -4
  16. package/compiled/sirv/index.js +8 -4
  17. package/compiled/sirv/package.json +1 -1
  18. package/compiled/style-loader/index.js +10 -10
  19. package/compiled/tinyglobby/index.d.ts +1 -0
  20. package/compiled/tinyglobby/index.js +266 -142
  21. package/compiled/tinyglobby/package.json +1 -1
  22. package/compiled/webpack-bundle-analyzer/index.js +6 -2
  23. package/compiled/ws/index.js +50 -49
  24. package/compiled/ws/package.json +1 -1
  25. package/dist/client/hmr.js +2 -2
  26. package/dist/index.cjs +146 -93
  27. package/dist/index.js +142 -89
  28. package/dist-types/helpers/index.d.ts +4 -3
  29. package/dist-types/index.d.ts +1 -1
  30. package/dist-types/loadEnv.d.ts +16 -4
  31. package/dist-types/logger.d.ts +14 -0
  32. package/dist-types/server/devServer.d.ts +2 -1
  33. package/dist-types/server/socketServer.d.ts +4 -2
  34. package/dist-types/types/config.d.ts +79 -43
  35. package/dist-types/types/rspack.d.ts +1 -1
  36. package/package.json +12 -12
  37. package/compiled/jiti/index.d.ts +0 -1
  38. package/compiled/jiti/index.js +0 -416
  39. package/compiled/jiti/license +0 -21
  40. package/compiled/jiti/package.json +0 -1
@@ -1,10 +1,10 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 357: (__unused_webpack_module, exports, __nccwpck_require__) => {
4
+ 68: (__unused_webpack_module, exports, __nccwpck_require__) => {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.callback = exports.promise = void 0;
7
- const walker_1 = __nccwpck_require__(531);
7
+ const walker_1 = __nccwpck_require__(188);
8
8
  function promise(root, options) {
9
9
  return new Promise((resolve, reject) => {
10
10
  callback(root, options, (err, output) => {
@@ -20,7 +20,7 @@
20
20
  }
21
21
  exports.callback = callback;
22
22
  },
23
- 369: (__unused_webpack_module, exports) => {
23
+ 120: (__unused_webpack_module, exports) => {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.Counter = void 0;
26
26
  class Counter {
@@ -44,7 +44,7 @@
44
44
  }
45
45
  exports.Counter = Counter;
46
46
  },
47
- 875: (__unused_webpack_module, exports) => {
47
+ 366: (__unused_webpack_module, exports) => {
48
48
  Object.defineProperty(exports, "__esModule", { value: true });
49
49
  exports.build = void 0;
50
50
  const getArray = (paths) => paths;
@@ -54,7 +54,7 @@
54
54
  }
55
55
  exports.build = build;
56
56
  },
57
- 778: (__unused_webpack_module, exports) => {
57
+ 863: (__unused_webpack_module, exports) => {
58
58
  Object.defineProperty(exports, "__esModule", { value: true });
59
59
  exports.build = void 0;
60
60
  const groupFiles = (groups, directory, files) => {
@@ -66,7 +66,7 @@
66
66
  }
67
67
  exports.build = build;
68
68
  },
69
- 627: (__unused_webpack_module, exports) => {
69
+ 918: (__unused_webpack_module, exports) => {
70
70
  Object.defineProperty(exports, "__esModule", { value: true });
71
71
  exports.build = void 0;
72
72
  const onlyCountsSync = (state) => state.counts;
@@ -109,14 +109,14 @@
109
109
  }
110
110
  exports.build = build;
111
111
  },
112
- 347: (__unused_webpack_module, exports, __nccwpck_require__) => {
112
+ 554: (__unused_webpack_module, exports, __nccwpck_require__) => {
113
113
  Object.defineProperty(exports, "__esModule", { value: true });
114
114
  exports.build =
115
115
  exports.joinDirectoryPath =
116
116
  exports.joinPathWithBasePath =
117
117
  void 0;
118
118
  const path_1 = __nccwpck_require__(928);
119
- const utils_1 = __nccwpck_require__(215);
119
+ const utils_1 = __nccwpck_require__(662);
120
120
  function joinPathWithBasePath(filename, directoryPath) {
121
121
  return directoryPath + filename;
122
122
  }
@@ -153,7 +153,7 @@
153
153
  }
154
154
  exports.build = build;
155
155
  },
156
- 937: (__unused_webpack_module, exports) => {
156
+ 230: (__unused_webpack_module, exports) => {
157
157
  Object.defineProperty(exports, "__esModule", { value: true });
158
158
  exports.build = void 0;
159
159
  function pushDirectoryWithRelativePath(root) {
@@ -190,7 +190,7 @@
190
190
  }
191
191
  exports.build = build;
192
192
  },
193
- 650: (__unused_webpack_module, exports) => {
193
+ 871: (__unused_webpack_module, exports) => {
194
194
  Object.defineProperty(exports, "__esModule", { value: true });
195
195
  exports.build = void 0;
196
196
  const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
@@ -220,7 +220,7 @@
220
220
  }
221
221
  exports.build = build;
222
222
  },
223
- 329: function (__unused_webpack_module, exports, __nccwpck_require__) {
223
+ 904: function (__unused_webpack_module, exports, __nccwpck_require__) {
224
224
  var __importDefault =
225
225
  (this && this.__importDefault) ||
226
226
  function (mod) {
@@ -291,7 +291,7 @@
291
291
  return state.visited.includes(resolved + state.options.pathSeparator);
292
292
  }
293
293
  },
294
- 632: function (__unused_webpack_module, exports, __nccwpck_require__) {
294
+ 747: function (__unused_webpack_module, exports, __nccwpck_require__) {
295
295
  var __importDefault =
296
296
  (this && this.__importDefault) ||
297
297
  function (mod) {
@@ -347,7 +347,7 @@
347
347
  }
348
348
  exports.build = build;
349
349
  },
350
- 26: (__unused_webpack_module, exports) => {
350
+ 583: (__unused_webpack_module, exports) => {
351
351
  Object.defineProperty(exports, "__esModule", { value: true });
352
352
  exports.Queue = void 0;
353
353
  class Queue {
@@ -365,17 +365,17 @@
365
365
  }
366
366
  exports.Queue = Queue;
367
367
  },
368
- 942: (__unused_webpack_module, exports, __nccwpck_require__) => {
368
+ 181: (__unused_webpack_module, exports, __nccwpck_require__) => {
369
369
  Object.defineProperty(exports, "__esModule", { value: true });
370
370
  exports.sync = void 0;
371
- const walker_1 = __nccwpck_require__(531);
371
+ const walker_1 = __nccwpck_require__(188);
372
372
  function sync(root, options) {
373
373
  const walker = new walker_1.Walker(root, options);
374
374
  return walker.start();
375
375
  }
376
376
  exports.sync = sync;
377
377
  },
378
- 531: function (__unused_webpack_module, exports, __nccwpck_require__) {
378
+ 188: function (__unused_webpack_module, exports, __nccwpck_require__) {
379
379
  var __createBinding =
380
380
  (this && this.__createBinding) ||
381
381
  (Object.create
@@ -431,17 +431,17 @@
431
431
  Object.defineProperty(exports, "__esModule", { value: true });
432
432
  exports.Walker = void 0;
433
433
  const path_1 = __nccwpck_require__(928);
434
- const utils_1 = __nccwpck_require__(215);
435
- const joinPath = __importStar(__nccwpck_require__(347));
436
- const pushDirectory = __importStar(__nccwpck_require__(937));
437
- const pushFile = __importStar(__nccwpck_require__(650));
438
- const getArray = __importStar(__nccwpck_require__(875));
439
- const groupFiles = __importStar(__nccwpck_require__(778));
440
- const resolveSymlink = __importStar(__nccwpck_require__(329));
441
- const invokeCallback = __importStar(__nccwpck_require__(627));
442
- const walkDirectory = __importStar(__nccwpck_require__(632));
443
- const queue_1 = __nccwpck_require__(26);
444
- const counter_1 = __nccwpck_require__(369);
434
+ const utils_1 = __nccwpck_require__(662);
435
+ const joinPath = __importStar(__nccwpck_require__(554));
436
+ const pushDirectory = __importStar(__nccwpck_require__(230));
437
+ const pushFile = __importStar(__nccwpck_require__(871));
438
+ const getArray = __importStar(__nccwpck_require__(366));
439
+ const groupFiles = __importStar(__nccwpck_require__(863));
440
+ const resolveSymlink = __importStar(__nccwpck_require__(904));
441
+ const invokeCallback = __importStar(__nccwpck_require__(918));
442
+ const walkDirectory = __importStar(__nccwpck_require__(747));
443
+ const queue_1 = __nccwpck_require__(583);
444
+ const counter_1 = __nccwpck_require__(120);
445
445
  class Walker {
446
446
  root;
447
447
  isSynchronous;
@@ -544,7 +544,14 @@
544
544
  resolvedPath,
545
545
  this.state.options,
546
546
  );
547
- if (exclude && exclude(entry.name, resolvedPath)) return;
547
+ if (
548
+ exclude &&
549
+ exclude(
550
+ entry.name,
551
+ useRealPaths ? resolvedPath : path + pathSeparator,
552
+ )
553
+ )
554
+ return;
548
555
  this.walkDirectory(
549
556
  this.state,
550
557
  resolvedPath,
@@ -575,11 +582,11 @@
575
582
  }
576
583
  exports.Walker = Walker;
577
584
  },
578
- 272: (__unused_webpack_module, exports, __nccwpck_require__) => {
585
+ 737: (__unused_webpack_module, exports, __nccwpck_require__) => {
579
586
  Object.defineProperty(exports, "__esModule", { value: true });
580
587
  exports.APIBuilder = void 0;
581
- const async_1 = __nccwpck_require__(357);
582
- const sync_1 = __nccwpck_require__(942);
588
+ const async_1 = __nccwpck_require__(68);
589
+ const sync_1 = __nccwpck_require__(181);
583
590
  class APIBuilder {
584
591
  root;
585
592
  options;
@@ -599,11 +606,11 @@
599
606
  }
600
607
  exports.APIBuilder = APIBuilder;
601
608
  },
602
- 498: (__unused_webpack_module, exports, __nccwpck_require__) => {
609
+ 523: (__unused_webpack_module, exports, __nccwpck_require__) => {
603
610
  Object.defineProperty(exports, "__esModule", { value: true });
604
611
  exports.Builder = void 0;
605
612
  const path_1 = __nccwpck_require__(928);
606
- const api_builder_1 = __nccwpck_require__(272);
613
+ const api_builder_1 = __nccwpck_require__(737);
607
614
  var pm = null;
608
615
  try {
609
616
  __nccwpck_require__.ab + "index1.js";
@@ -724,7 +731,7 @@
724
731
  }
725
732
  exports.Builder = Builder;
726
733
  },
727
- 846: function (__unused_webpack_module, exports, __nccwpck_require__) {
734
+ 923: function (__unused_webpack_module, exports, __nccwpck_require__) {
728
735
  var __createBinding =
729
736
  (this && this.__createBinding) ||
730
737
  (Object.create
@@ -762,19 +769,19 @@
762
769
  };
763
770
  Object.defineProperty(exports, "__esModule", { value: true });
764
771
  exports.fdir = void 0;
765
- const builder_1 = __nccwpck_require__(498);
772
+ const builder_1 = __nccwpck_require__(523);
766
773
  Object.defineProperty(exports, "fdir", {
767
774
  enumerable: true,
768
775
  get: function () {
769
776
  return builder_1.Builder;
770
777
  },
771
778
  });
772
- __exportStar(__nccwpck_require__(971), exports);
779
+ __exportStar(__nccwpck_require__(906), exports);
773
780
  },
774
- 971: (__unused_webpack_module, exports) => {
781
+ 906: (__unused_webpack_module, exports) => {
775
782
  Object.defineProperty(exports, "__esModule", { value: true });
776
783
  },
777
- 215: (__unused_webpack_module, exports, __nccwpck_require__) => {
784
+ 662: (__unused_webpack_module, exports, __nccwpck_require__) => {
778
785
  Object.defineProperty(exports, "__esModule", { value: true });
779
786
  exports.normalizePath =
780
787
  exports.convertSlashes =
@@ -2394,7 +2401,7 @@
2394
2401
  return last;
2395
2402
  };
2396
2403
  },
2397
- 572: (module, __unused_webpack_exports, __nccwpck_require__) => {
2404
+ 606: (module, __unused_webpack_exports, __nccwpck_require__) => {
2398
2405
  var __create = Object.create;
2399
2406
  var __defProp = Object.defineProperty;
2400
2407
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -2428,19 +2435,78 @@
2428
2435
  );
2429
2436
  var __toCommonJS = (mod) =>
2430
2437
  __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2431
- var src_exports = {};
2432
- __export(src_exports, {
2438
+ var index_exports = {};
2439
+ __export(index_exports, {
2433
2440
  convertPathToPattern: () => convertPathToPattern,
2434
2441
  escapePath: () => escapePath,
2435
2442
  glob: () => glob,
2436
2443
  globSync: () => globSync,
2437
2444
  isDynamicPattern: () => isDynamicPattern,
2438
2445
  });
2439
- module.exports = __toCommonJS(src_exports);
2446
+ module.exports = __toCommonJS(index_exports);
2440
2447
  var import_node_path = __toESM(__nccwpck_require__(928));
2441
- var import_fdir = __nccwpck_require__(846);
2448
+ var import_fdir = __nccwpck_require__(923);
2442
2449
  var import_picomatch2 = __toESM(__nccwpck_require__(976));
2443
2450
  var import_picomatch = __toESM(__nccwpck_require__(976));
2451
+ var ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
2452
+ function getPartialMatcher(patterns, options) {
2453
+ const patternsCount = patterns.length;
2454
+ const patternsParts = Array(patternsCount);
2455
+ const regexes = Array(patternsCount);
2456
+ for (let i = 0; i < patternsCount; i++) {
2457
+ const parts = splitPattern(patterns[i]);
2458
+ patternsParts[i] = parts;
2459
+ const partsCount = parts.length;
2460
+ const partRegexes = Array(partsCount);
2461
+ for (let j = 0; j < partsCount; j++) {
2462
+ partRegexes[j] = import_picomatch.default.makeRe(parts[j], options);
2463
+ }
2464
+ regexes[i] = partRegexes;
2465
+ }
2466
+ return (input) => {
2467
+ const inputParts = input.split("/");
2468
+ if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) {
2469
+ return true;
2470
+ }
2471
+ for (let i = 0; i < patterns.length; i++) {
2472
+ const patternParts = patternsParts[i];
2473
+ const regex = regexes[i];
2474
+ const inputPatternCount = inputParts.length;
2475
+ const minParts = Math.min(inputPatternCount, patternParts.length);
2476
+ let j = 0;
2477
+ while (j < minParts) {
2478
+ const part = patternParts[j];
2479
+ if (part.includes("/")) {
2480
+ return true;
2481
+ }
2482
+ const match = regex[j].test(inputParts[j]);
2483
+ if (!match) {
2484
+ break;
2485
+ }
2486
+ if (part === "**") {
2487
+ return true;
2488
+ }
2489
+ j++;
2490
+ }
2491
+ if (j === inputPatternCount) {
2492
+ return true;
2493
+ }
2494
+ }
2495
+ return false;
2496
+ };
2497
+ }
2498
+ var splitPatternOptions = { parts: true };
2499
+ function splitPattern(path2) {
2500
+ var _a;
2501
+ const result = import_picomatch.default.scan(
2502
+ path2,
2503
+ splitPatternOptions,
2504
+ );
2505
+ return ((_a = result.parts) == null ? void 0 : _a.length)
2506
+ ? result.parts
2507
+ : [path2];
2508
+ }
2509
+ var isWin = process.platform === "win32";
2444
2510
  var ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
2445
2511
  function convertPosixPathToPattern(path2) {
2446
2512
  return escapePosixPath(path2);
@@ -2448,10 +2514,9 @@
2448
2514
  function convertWin32PathToPattern(path2) {
2449
2515
  return escapeWin32Path(path2).replace(ESCAPED_WIN32_BACKSLASHES, "/");
2450
2516
  }
2451
- var convertPathToPattern =
2452
- process.platform === "win32"
2453
- ? convertWin32PathToPattern
2454
- : convertPosixPathToPattern;
2517
+ var convertPathToPattern = isWin
2518
+ ? convertWin32PathToPattern
2519
+ : convertPosixPathToPattern;
2455
2520
  var POSIX_UNESCAPED_GLOB_SYMBOLS =
2456
2521
  /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
2457
2522
  var WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
@@ -2459,8 +2524,7 @@
2459
2524
  path2.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2460
2525
  var escapeWin32Path = (path2) =>
2461
2526
  path2.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2462
- var escapePath =
2463
- process.platform === "win32" ? escapeWin32Path : escapePosixPath;
2527
+ var escapePath = isWin ? escapeWin32Path : escapePosixPath;
2464
2528
  function isDynamicPattern(pattern, options) {
2465
2529
  if ((options == null ? void 0 : options.caseSensitiveMatch) === false) {
2466
2530
  return true;
@@ -2468,11 +2532,20 @@
2468
2532
  const scan = import_picomatch.default.scan(pattern);
2469
2533
  return scan.isGlob || scan.negated;
2470
2534
  }
2535
+ function log(...tasks) {
2536
+ console.log(
2537
+ `[tinyglobby ${new Date().toLocaleTimeString("es")}]`,
2538
+ ...tasks,
2539
+ );
2540
+ }
2541
+ var PARENT_DIRECTORY = /^(\/?\.\.)+/;
2542
+ var ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
2543
+ var BACKSLASHES = /\\/g;
2471
2544
  function normalizePattern(
2472
2545
  pattern,
2473
2546
  expandDirectories,
2474
2547
  cwd,
2475
- properties,
2548
+ props,
2476
2549
  isIgnore,
2477
2550
  ) {
2478
2551
  var _a;
@@ -2485,51 +2558,46 @@
2485
2558
  }
2486
2559
  if (
2487
2560
  import_node_path.default.isAbsolute(
2488
- result.replace(/\\(?=[()[\]{}!*+?@|])/g, ""),
2561
+ result.replace(ESCAPING_BACKSLASHES, ""),
2489
2562
  )
2490
2563
  ) {
2491
- result = import_node_path.posix.relative(cwd, result);
2564
+ result = import_node_path.posix.relative(escapePath(cwd), result);
2492
2565
  } else {
2493
2566
  result = import_node_path.posix.normalize(result);
2494
2567
  }
2495
- const parentDirectoryMatch = /^(\/?\.\.)+/.exec(result);
2568
+ const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
2496
2569
  if (parentDirectoryMatch == null ? void 0 : parentDirectoryMatch[0]) {
2497
2570
  const potentialRoot = import_node_path.posix.join(
2498
2571
  cwd,
2499
2572
  parentDirectoryMatch[0],
2500
2573
  );
2501
- if (properties.root.length > potentialRoot.length) {
2502
- properties.root = potentialRoot;
2503
- properties.depthOffset = -(parentDirectoryMatch[0].length + 1) / 3;
2504
- }
2505
- } else if (!isIgnore && properties.depthOffset >= 0) {
2506
- const current = result.split("/");
2507
- (_a = properties.commonPath) != null
2508
- ? _a
2509
- : (properties.commonPath = current);
2574
+ if (props.root.length > potentialRoot.length) {
2575
+ props.root = potentialRoot;
2576
+ props.depthOffset = -(parentDirectoryMatch[0].length + 1) / 3;
2577
+ }
2578
+ } else if (!isIgnore && props.depthOffset >= 0) {
2579
+ const parts = splitPattern(result);
2580
+ (_a = props.commonPath) != null ? _a : (props.commonPath = parts);
2510
2581
  const newCommonPath = [];
2511
- for (
2512
- let i = 0;
2513
- i < Math.min(properties.commonPath.length, current.length);
2514
- i++
2515
- ) {
2516
- const part = current[i];
2517
- if (part === "**" && !current[i + 1]) {
2582
+ const length = Math.min(props.commonPath.length, parts.length);
2583
+ for (let i = 0; i < length; i++) {
2584
+ const part = parts[i];
2585
+ if (part === "**" && !parts[i + 1]) {
2518
2586
  newCommonPath.pop();
2519
2587
  break;
2520
2588
  }
2521
2589
  if (
2522
- part !== properties.commonPath[i] ||
2590
+ part !== props.commonPath[i] ||
2523
2591
  isDynamicPattern(part) ||
2524
- i === current.length - 1
2592
+ i === parts.length - 1
2525
2593
  ) {
2526
2594
  break;
2527
2595
  }
2528
2596
  newCommonPath.push(part);
2529
2597
  }
2530
- properties.depthOffset = newCommonPath.length;
2531
- properties.commonPath = newCommonPath;
2532
- properties.root =
2598
+ props.depthOffset = newCommonPath.length;
2599
+ props.commonPath = newCommonPath;
2600
+ props.root =
2533
2601
  newCommonPath.length > 0
2534
2602
  ? `${cwd}/${newCommonPath.join("/")}`
2535
2603
  : cwd;
@@ -2539,7 +2607,7 @@
2539
2607
  function processPatterns(
2540
2608
  { patterns, ignore = [], expandDirectories = true },
2541
2609
  cwd,
2542
- properties,
2610
+ props,
2543
2611
  ) {
2544
2612
  if (typeof patterns === "string") {
2545
2613
  patterns = [patterns];
@@ -2552,42 +2620,39 @@
2552
2620
  const matchPatterns = [];
2553
2621
  const ignorePatterns = [];
2554
2622
  for (const pattern of ignore) {
2555
- if (!pattern.startsWith("!") || pattern[1] === "(") {
2556
- const newPattern = normalizePattern(
2557
- pattern,
2558
- expandDirectories,
2559
- cwd,
2560
- properties,
2561
- true,
2623
+ if (!pattern) {
2624
+ continue;
2625
+ }
2626
+ if (pattern[0] !== "!" || pattern[1] === "(") {
2627
+ ignorePatterns.push(
2628
+ normalizePattern(pattern, expandDirectories, cwd, props, true),
2562
2629
  );
2563
- ignorePatterns.push(newPattern);
2564
2630
  }
2565
2631
  }
2566
2632
  for (const pattern of patterns) {
2567
- if (!pattern.startsWith("!") || pattern[1] === "(") {
2568
- const newPattern = normalizePattern(
2569
- pattern,
2570
- expandDirectories,
2571
- cwd,
2572
- properties,
2573
- false,
2633
+ if (!pattern) {
2634
+ continue;
2635
+ }
2636
+ if (pattern[0] !== "!" || pattern[1] === "(") {
2637
+ matchPatterns.push(
2638
+ normalizePattern(pattern, expandDirectories, cwd, props, false),
2574
2639
  );
2575
- matchPatterns.push(newPattern);
2576
2640
  } else if (pattern[1] !== "!" || pattern[2] === "(") {
2577
- const newPattern = normalizePattern(
2578
- pattern.slice(1),
2579
- expandDirectories,
2580
- cwd,
2581
- properties,
2582
- true,
2641
+ ignorePatterns.push(
2642
+ normalizePattern(
2643
+ pattern.slice(1),
2644
+ expandDirectories,
2645
+ cwd,
2646
+ props,
2647
+ true,
2648
+ ),
2583
2649
  );
2584
- ignorePatterns.push(newPattern);
2585
2650
  }
2586
2651
  }
2587
2652
  return { match: matchPatterns, ignore: ignorePatterns };
2588
2653
  }
2589
2654
  function getRelativePath(path2, cwd, root) {
2590
- return import_node_path.posix.relative(cwd, `${root}/${path2}`);
2655
+ return import_node_path.posix.relative(cwd, `${root}/${path2}`) || ".";
2591
2656
  }
2592
2657
  function processPath(path2, cwd, root, isDirectory, absolute) {
2593
2658
  const relativePath = absolute
@@ -2600,41 +2665,110 @@
2600
2665
  }
2601
2666
  return getRelativePath(relativePath, cwd, root);
2602
2667
  }
2668
+ function formatPaths(paths, cwd, root) {
2669
+ for (let i = paths.length - 1; i >= 0; i--) {
2670
+ const path2 = paths[i];
2671
+ paths[i] =
2672
+ getRelativePath(path2, cwd, root) +
2673
+ (!path2 || path2.endsWith("/") ? "/" : "");
2674
+ }
2675
+ return paths;
2676
+ }
2603
2677
  function crawl(options, cwd, sync) {
2604
- const properties = { root: cwd, commonPath: null, depthOffset: 0 };
2605
- const processed = processPatterns(options, cwd, properties);
2678
+ if (process.env.TINYGLOBBY_DEBUG) {
2679
+ options.debug = true;
2680
+ }
2681
+ if (options.debug) {
2682
+ log("globbing with options:", options, "cwd:", cwd);
2683
+ }
2684
+ if (Array.isArray(options.patterns) && options.patterns.length === 0) {
2685
+ return sync ? [] : Promise.resolve([]);
2686
+ }
2687
+ const props = { root: cwd, commonPath: null, depthOffset: 0 };
2688
+ const processed = processPatterns(options, cwd, props);
2689
+ const nocase = options.caseSensitiveMatch === false;
2690
+ if (options.debug) {
2691
+ log("internal processing patterns:", processed);
2692
+ }
2606
2693
  const matcher = (0, import_picomatch2.default)(processed.match, {
2607
2694
  dot: options.dot,
2608
- nocase: options.caseSensitiveMatch === false,
2695
+ nocase,
2609
2696
  ignore: processed.ignore,
2610
2697
  });
2611
- const exclude = (0, import_picomatch2.default)(processed.ignore, {
2698
+ const ignore = (0, import_picomatch2.default)(processed.ignore, {
2699
+ dot: options.dot,
2700
+ nocase,
2701
+ });
2702
+ const partialMatcher = getPartialMatcher(processed.match, {
2612
2703
  dot: options.dot,
2613
- nocase: options.caseSensitiveMatch === false,
2704
+ nocase,
2614
2705
  });
2615
2706
  const fdirOptions = {
2616
2707
  filters: [
2617
- (p, isDirectory) =>
2618
- matcher(
2619
- processPath(
2708
+ options.debug
2709
+ ? (p, isDirectory) => {
2710
+ const path2 = processPath(
2711
+ p,
2712
+ cwd,
2713
+ props.root,
2714
+ isDirectory,
2715
+ options.absolute,
2716
+ );
2717
+ const matches = matcher(path2);
2718
+ if (matches) {
2719
+ log(`matched ${path2}`);
2720
+ }
2721
+ return matches;
2722
+ }
2723
+ : (p, isDirectory) =>
2724
+ matcher(
2725
+ processPath(
2726
+ p,
2727
+ cwd,
2728
+ props.root,
2729
+ isDirectory,
2730
+ options.absolute,
2731
+ ),
2732
+ ),
2733
+ ],
2734
+ exclude: options.debug
2735
+ ? (_, p) => {
2736
+ const relativePath = processPath(
2620
2737
  p,
2621
2738
  cwd,
2622
- properties.root,
2623
- isDirectory,
2624
- options.absolute,
2625
- ),
2626
- ),
2627
- ],
2628
- exclude: (_, p) =>
2629
- exclude(processPath(p, cwd, properties.root, true, true)),
2739
+ props.root,
2740
+ true,
2741
+ true,
2742
+ );
2743
+ const skipped =
2744
+ (relativePath !== "." && !partialMatcher(relativePath)) ||
2745
+ ignore(relativePath);
2746
+ if (skipped) {
2747
+ log(`skipped ${p}`);
2748
+ } else {
2749
+ log(`crawling ${p}`);
2750
+ }
2751
+ return skipped;
2752
+ }
2753
+ : (_, p) => {
2754
+ const relativePath = processPath(
2755
+ p,
2756
+ cwd,
2757
+ props.root,
2758
+ true,
2759
+ true,
2760
+ );
2761
+ return (
2762
+ (relativePath !== "." && !partialMatcher(relativePath)) ||
2763
+ ignore(relativePath)
2764
+ );
2765
+ },
2630
2766
  pathSeparator: "/",
2631
2767
  relativePaths: true,
2632
2768
  resolveSymlinks: true,
2633
2769
  };
2634
2770
  if (options.deep) {
2635
- fdirOptions.maxDepth = Math.round(
2636
- options.deep - properties.depthOffset,
2637
- );
2771
+ fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
2638
2772
  }
2639
2773
  if (options.absolute) {
2640
2774
  fdirOptions.relativePaths = false;
@@ -2651,28 +2785,18 @@
2651
2785
  } else if (options.onlyFiles === false) {
2652
2786
  fdirOptions.includeDirs = true;
2653
2787
  }
2654
- properties.root = properties.root.replace(/\\/g, "");
2655
- const api = new import_fdir.fdir(fdirOptions).crawl(properties.root);
2656
- if (cwd === properties.root || options.absolute) {
2788
+ props.root = props.root.replace(BACKSLASHES, "");
2789
+ const root = props.root;
2790
+ if (options.debug) {
2791
+ log("internal properties:", props);
2792
+ }
2793
+ const api = new import_fdir.fdir(fdirOptions).crawl(root);
2794
+ if (cwd === root || options.absolute) {
2657
2795
  return sync ? api.sync() : api.withPromise();
2658
2796
  }
2659
2797
  return sync
2660
- ? api
2661
- .sync()
2662
- .map(
2663
- (p) =>
2664
- getRelativePath(p, cwd, properties.root) +
2665
- (!p || p.endsWith("/") ? "/" : ""),
2666
- )
2667
- : api
2668
- .withPromise()
2669
- .then((paths) =>
2670
- paths.map(
2671
- (p) =>
2672
- getRelativePath(p, cwd, properties.root) +
2673
- (!p || p.endsWith("/") ? "/" : ""),
2674
- ),
2675
- );
2798
+ ? formatPaths(api.sync(), cwd, root)
2799
+ : api.withPromise().then((paths) => formatPaths(paths, cwd, root));
2676
2800
  }
2677
2801
  async function glob(patternsOrOptions, options) {
2678
2802
  if (
@@ -2689,8 +2813,8 @@
2689
2813
  ? { ...options, patterns: patternsOrOptions }
2690
2814
  : patternsOrOptions;
2691
2815
  const cwd = opts.cwd
2692
- ? import_node_path.default.resolve(opts.cwd).replace(/\\/g, "/")
2693
- : process.cwd().replace(/\\/g, "/");
2816
+ ? import_node_path.default.resolve(opts.cwd).replace(BACKSLASHES, "/")
2817
+ : process.cwd().replace(BACKSLASHES, "/");
2694
2818
  return crawl(opts, cwd, false);
2695
2819
  }
2696
2820
  function globSync(patternsOrOptions, options) {
@@ -2708,8 +2832,8 @@
2708
2832
  ? { ...options, patterns: patternsOrOptions }
2709
2833
  : patternsOrOptions;
2710
2834
  const cwd = opts.cwd
2711
- ? import_node_path.default.resolve(opts.cwd).replace(/\\/g, "/")
2712
- : process.cwd().replace(/\\/g, "/");
2835
+ ? import_node_path.default.resolve(opts.cwd).replace(BACKSLASHES, "/")
2836
+ : process.cwd().replace(BACKSLASHES, "/");
2713
2837
  return crawl(opts, cwd, true);
2714
2838
  }
2715
2839
  0 && 0;
@@ -2744,6 +2868,6 @@
2744
2868
  }
2745
2869
  if (typeof __nccwpck_require__ !== "undefined")
2746
2870
  __nccwpck_require__.ab = __dirname + "/";
2747
- var __webpack_exports__ = __nccwpck_require__(572);
2871
+ var __webpack_exports__ = __nccwpck_require__(606);
2748
2872
  module.exports = __webpack_exports__;
2749
2873
  })();