deslop-js 0.0.19 → 0.0.20-dev.867c5c6

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/index.cjs CHANGED
@@ -41,6 +41,7 @@ let node_os = require("node:os");
41
41
  node_os = __toESM(node_os, 1);
42
42
  let oxc_resolver = require("oxc-resolver");
43
43
  let minimatch = require("minimatch");
44
+ let node_child_process = require("node:child_process");
44
45
 
45
46
  //#region src/constants.ts
46
47
  const DEFAULT_EXTENSIONS = [
@@ -348,6 +349,7 @@ const DEFAULT_SEMANTIC_TSCONFIG_NAMES = [
348
349
  "tsconfig.src.json",
349
350
  "jsconfig.json"
350
351
  ];
352
+ const GIT_CHECK_IGNORE_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
351
353
 
352
354
  //#endregion
353
355
  //#region src/errors.ts
@@ -4881,7 +4883,7 @@ const extractNextConfigPluginFiles = (directory) => {
4881
4883
  const VITEST_INCLUDE_ITEM_PATTERN = /['"]([^'"]+)['"]/g;
4882
4884
  const COVERAGE_BLOCK_PATTERN = /coverage\s*:\s*\{/g;
4883
4885
  const TEST_MATCH_ARRAY_PATTERN = /testMatch\s*:\s*\[([^\]]*)\]/;
4884
- const STRING_LITERAL_PATTERN = /['"]([^'"]+)['"]/g;
4886
+ const STRING_LITERAL_PATTERN$1 = /['"]([^'"]+)['"]/g;
4885
4887
  const extractJestTestMatchPatterns = (directory) => {
4886
4888
  const configPaths = fast_glob.default.sync(["jest.config.{ts,js,mjs,cjs}"], {
4887
4889
  cwd: directory,
@@ -4903,9 +4905,9 @@ const extractJestTestMatchPatterns = (directory) => {
4903
4905
  if (!testMatchMatch) continue;
4904
4906
  const arrayContent = testMatchMatch[1];
4905
4907
  const patterns = [];
4906
- STRING_LITERAL_PATTERN.lastIndex = 0;
4908
+ STRING_LITERAL_PATTERN$1.lastIndex = 0;
4907
4909
  let itemMatch;
4908
- while ((itemMatch = STRING_LITERAL_PATTERN.exec(arrayContent)) !== null) patterns.push(itemMatch[1]);
4910
+ while ((itemMatch = STRING_LITERAL_PATTERN$1.exec(arrayContent)) !== null) patterns.push(itemMatch[1]);
4909
4911
  if (patterns.length > 0) return convertJestTestMatchToGlobs(patterns);
4910
4912
  } catch {}
4911
4913
  return [];
@@ -6322,6 +6324,19 @@ const isPlatformBuiltinOrVirtualSpecifier = (specifier) => {
6322
6324
  return BUILTIN_SUBPATH_NODE_MODULES.has(baseName);
6323
6325
  };
6324
6326
 
6327
+ //#endregion
6328
+ //#region src/utils/sanitize-import-specifier.ts
6329
+ const sanitizeImportSpecifier = (specifier) => {
6330
+ if (specifier.startsWith("node:") || specifier.startsWith("data:") || specifier.includes("://")) return specifier;
6331
+ const lastLoaderSeparator = specifier.lastIndexOf("!");
6332
+ let cleaned = lastLoaderSeparator === -1 ? specifier : specifier.slice(lastLoaderSeparator + 1);
6333
+ const queryIndex = cleaned.indexOf("?");
6334
+ if (queryIndex !== -1) cleaned = cleaned.slice(0, queryIndex);
6335
+ const fragmentIndex = cleaned.indexOf("#", 1);
6336
+ if (fragmentIndex !== -1) cleaned = cleaned.slice(0, fragmentIndex);
6337
+ return cleaned || specifier;
6338
+ };
6339
+
6325
6340
  //#endregion
6326
6341
  //#region src/resolver/resolve.ts
6327
6342
  const fileExistsCache = /* @__PURE__ */ new Map();
@@ -6386,6 +6401,50 @@ const resolvePathWithExtensionFallback = (candidatePath) => {
6386
6401
  }
6387
6402
  return candidatePath;
6388
6403
  };
6404
+ const resolveAliasTarget = (target) => {
6405
+ if (existsAsFile(target)) return target;
6406
+ for (const extension of RESOLVER_EXTENSIONS) if (cachedExistsSync(target + extension)) return target + extension;
6407
+ const sourceTarget = target.replace(/\.[cm]?js$/, "");
6408
+ if (sourceTarget !== target) {
6409
+ for (const extension of RESOLVER_EXTENSIONS) if (cachedExistsSync(sourceTarget + extension)) return sourceTarget + extension;
6410
+ }
6411
+ const indexCandidate = (0, node_path.join)(target, "index");
6412
+ for (const extension of RESOLVER_EXTENSIONS) if (cachedExistsSync(indexCandidate + extension)) return indexCandidate + extension;
6413
+ };
6414
+ const pathMappingSpecificity = (mapping) => mapping.isWildcard ? mapping.prefix.length + mapping.suffix.length : Number.MAX_SAFE_INTEGER;
6415
+ const compilePathMappings = (entries) => {
6416
+ const compiled = [];
6417
+ for (const [pattern, targets] of entries) {
6418
+ const wildcardIndex = pattern.indexOf("*");
6419
+ if (wildcardIndex === -1) compiled.push({
6420
+ prefix: pattern,
6421
+ suffix: "",
6422
+ isWildcard: false,
6423
+ targets
6424
+ });
6425
+ else compiled.push({
6426
+ prefix: pattern.slice(0, wildcardIndex),
6427
+ suffix: pattern.slice(wildcardIndex + 1),
6428
+ isWildcard: true,
6429
+ targets
6430
+ });
6431
+ }
6432
+ compiled.sort((left, right) => pathMappingSpecificity(right) - pathMappingSpecificity(left));
6433
+ return compiled;
6434
+ };
6435
+ const matchCompiledMapping = (specifier, mappings) => {
6436
+ for (const mapping of mappings) {
6437
+ let matchedWildcard = "";
6438
+ if (mapping.isWildcard) {
6439
+ if (!specifier.startsWith(mapping.prefix) || !specifier.endsWith(mapping.suffix)) continue;
6440
+ matchedWildcard = specifier.slice(mapping.prefix.length, specifier.length - mapping.suffix.length);
6441
+ } else if (specifier !== mapping.prefix) continue;
6442
+ for (const target of mapping.targets) {
6443
+ const resolved = resolveAliasTarget(target.replace("*", matchedWildcard));
6444
+ if (resolved) return resolved;
6445
+ }
6446
+ }
6447
+ };
6389
6448
  const COMMON_RESOLVER_OPTIONS = {
6390
6449
  conditionNames: [
6391
6450
  "import",
@@ -6417,11 +6476,26 @@ const WEBPACK_CONFIG_GLOBS = [
6417
6476
  "**/webpack.config*.{js,ts,mjs,cjs}",
6418
6477
  "**/webpack*.config*.babel.{js,ts}"
6419
6478
  ];
6420
- const WEBPACK_ALIAS_BLOCK_PATTERN = /alias\s*:\s*\{([\s\S]*?)\}/g;
6421
- const WEBPACK_ALIAS_ENTRY_PATTERN = /["']?([@\w$./-]+)["']?\s*:\s*(?:path\.(?:resolve|join)\(\s*__dirname\s*,\s*((?:["'][^"']+["']\s*,?\s*)+)\)|["']([^"']+)["'])/g;
6479
+ const VITE_CONFIG_GLOBS = [
6480
+ "vite.config.{js,ts,mjs,cjs,mts,cts}",
6481
+ "vitest.config.{js,ts,mjs,cjs,mts,cts}",
6482
+ "**/vite.config.{js,ts,mjs,cjs,mts,cts}",
6483
+ "**/vitest.config.{js,ts,mjs,cjs,mts,cts}"
6484
+ ];
6485
+ const BABEL_CONFIG_GLOBS = [
6486
+ "babel.config.{js,cjs,mjs,json}",
6487
+ ".babelrc",
6488
+ ".babelrc.{js,cjs,mjs,json}",
6489
+ "**/babel.config.{js,cjs,mjs,json}"
6490
+ ];
6491
+ const JEST_CONFIG_GLOBS = ["jest.config.{js,ts,mjs,cjs,json}", "**/jest.config.{js,ts,mjs,cjs,json}"];
6492
+ const ALIAS_BLOCK_PATTERN = /alias\s*:\s*\{([\s\S]*?)\}/g;
6493
+ const ALIAS_ENTRY_PATTERN = /["']?([@\w$./-]+)["']?\s*:\s*(?:path\.(?:resolve|join)\(\s*__dirname\s*,\s*((?:["'][^"']+["']\s*,?\s*)+)\)|fileURLToPath\(\s*new URL\(\s*["']([^"']+)["']\s*,\s*import\.meta\.url\s*\)\s*\)|["']([^"']+)["'])/g;
6494
+ const JEST_MODULE_NAME_MAPPER_BLOCK_PATTERN = /moduleNameMapper\s*:\s*\{([\s\S]*?)\}/g;
6495
+ const JEST_MODULE_NAME_MAPPER_ENTRY_PATTERN = /["']([^"']+)["']\s*:\s*["']([^"']+)["']/g;
6422
6496
  const WEBPACK_MODULES_BLOCK_PATTERN = /modules\s*:\s*\[([\s\S]*?)\]/g;
6423
6497
  const WEBPACK_PATH_CALL_PATTERN = /path\.(?:resolve|join)\(\s*__dirname\s*,\s*((?:["'][^"']+["']\s*,?\s*)+)\)/g;
6424
- const WEBPACK_STRING_LITERAL_PATTERN = /["']([^"']+)["']/g;
6498
+ const STRING_LITERAL_PATTERN = /["']([^"']+)["']/g;
6425
6499
  const TSCONFIG_FILENAMES = [
6426
6500
  "tsconfig.json",
6427
6501
  "tsconfig.web.json",
@@ -6478,15 +6552,15 @@ const isInsideDirectory = (filePath, directory) => {
6478
6552
  const extractQuotedSegments = (value) => {
6479
6553
  const segments = [];
6480
6554
  let segmentMatch;
6481
- WEBPACK_STRING_LITERAL_PATTERN.lastIndex = 0;
6482
- while ((segmentMatch = WEBPACK_STRING_LITERAL_PATTERN.exec(value)) !== null) segments.push(segmentMatch[1]);
6555
+ STRING_LITERAL_PATTERN.lastIndex = 0;
6556
+ while ((segmentMatch = STRING_LITERAL_PATTERN.exec(value)) !== null) segments.push(segmentMatch[1]);
6483
6557
  return segments;
6484
6558
  };
6485
- const resolveWebpackPathValue = (value, configDirectory) => {
6559
+ const resolveConfigPathValue = (value, configDirectory) => {
6486
6560
  if ((0, node_path.isAbsolute)(value)) return value;
6487
6561
  return (0, node_path.resolve)(configDirectory, value);
6488
6562
  };
6489
- const findWebpackConfigScope = (configPath, rootDir) => {
6563
+ const findConfigScope = (configPath, rootDir) => {
6490
6564
  let currentDirectory = (0, node_path.dirname)(configPath);
6491
6565
  const absoluteRoot = (0, node_path.resolve)(rootDir);
6492
6566
  while (currentDirectory.length >= absoluteRoot.length) {
@@ -6497,24 +6571,25 @@ const findWebpackConfigScope = (configPath, rootDir) => {
6497
6571
  }
6498
6572
  return absoluteRoot;
6499
6573
  };
6500
- const extractWebpackAliases = (content, configDirectory) => {
6574
+ const extractBundlerAliases = (content, configDirectory) => {
6501
6575
  const aliases = [];
6502
6576
  let aliasBlockMatch;
6503
- WEBPACK_ALIAS_BLOCK_PATTERN.lastIndex = 0;
6504
- while ((aliasBlockMatch = WEBPACK_ALIAS_BLOCK_PATTERN.exec(content)) !== null) {
6577
+ ALIAS_BLOCK_PATTERN.lastIndex = 0;
6578
+ while ((aliasBlockMatch = ALIAS_BLOCK_PATTERN.exec(content)) !== null) {
6505
6579
  const aliasBlock = aliasBlockMatch[1];
6506
6580
  let aliasEntryMatch;
6507
- WEBPACK_ALIAS_ENTRY_PATTERN.lastIndex = 0;
6508
- while ((aliasEntryMatch = WEBPACK_ALIAS_ENTRY_PATTERN.exec(aliasBlock)) !== null) {
6581
+ ALIAS_ENTRY_PATTERN.lastIndex = 0;
6582
+ while ((aliasEntryMatch = ALIAS_ENTRY_PATTERN.exec(aliasBlock)) !== null) {
6509
6583
  const rawName = aliasEntryMatch[1];
6510
6584
  const pathCallSegments = aliasEntryMatch[2];
6511
- const stringTarget = aliasEntryMatch[3];
6512
- if (!pathCallSegments && !stringTarget) continue;
6585
+ const fileUrlTarget = aliasEntryMatch[3];
6586
+ const stringTarget = aliasEntryMatch[4];
6513
6587
  const isExact = rawName.endsWith("$");
6514
6588
  const name = isExact ? rawName.slice(0, -1) : rawName.replace(/\/$/, "");
6515
6589
  let targetDirectory;
6516
6590
  if (pathCallSegments) targetDirectory = (0, node_path.resolve)(configDirectory, ...extractQuotedSegments(pathCallSegments));
6517
- else if (stringTarget) targetDirectory = resolveWebpackPathValue(stringTarget, configDirectory);
6591
+ else if (fileUrlTarget) targetDirectory = (0, node_path.resolve)(configDirectory, fileUrlTarget);
6592
+ else if (stringTarget) targetDirectory = resolveConfigPathValue(stringTarget, configDirectory);
6518
6593
  else continue;
6519
6594
  aliases.push({
6520
6595
  name,
@@ -6525,6 +6600,32 @@ const extractWebpackAliases = (content, configDirectory) => {
6525
6600
  }
6526
6601
  return aliases;
6527
6602
  };
6603
+ const compileJestModuleNameMapperAlias = (pattern, target, configDirectory) => {
6604
+ if (!target.includes("<rootDir>")) return void 0;
6605
+ const isWildcard = pattern.includes("(.*)") || pattern.includes("(.+)");
6606
+ const aliasName = pattern.replace(/^\^/, "").replace(/\$$/, "").replace(/\\(.)/g, "$1").replace(/\/?\((?:\.\*|\.\+)\)$/, "").replace(/\/$/, "");
6607
+ if (!aliasName) return void 0;
6608
+ return {
6609
+ name: aliasName,
6610
+ targetDirectory: (0, node_path.resolve)(target.replace(/<rootDir>/g, configDirectory).replace(/\/?\$\d+$/, "")),
6611
+ isExact: !isWildcard
6612
+ };
6613
+ };
6614
+ const extractJestModuleNameMapperAliases = (content, configDirectory) => {
6615
+ const aliases = [];
6616
+ let blockMatch;
6617
+ JEST_MODULE_NAME_MAPPER_BLOCK_PATTERN.lastIndex = 0;
6618
+ while ((blockMatch = JEST_MODULE_NAME_MAPPER_BLOCK_PATTERN.exec(content)) !== null) {
6619
+ const block = blockMatch[1];
6620
+ let entryMatch;
6621
+ JEST_MODULE_NAME_MAPPER_ENTRY_PATTERN.lastIndex = 0;
6622
+ while ((entryMatch = JEST_MODULE_NAME_MAPPER_ENTRY_PATTERN.exec(block)) !== null) {
6623
+ const alias = compileJestModuleNameMapperAlias(entryMatch[1], entryMatch[2], configDirectory);
6624
+ if (alias) aliases.push(alias);
6625
+ }
6626
+ }
6627
+ return aliases;
6628
+ };
6528
6629
  const extractWebpackModuleDirectories = (content, configDirectory) => {
6529
6630
  const moduleDirectories = [];
6530
6631
  let modulesBlockMatch;
@@ -6535,17 +6636,39 @@ const extractWebpackModuleDirectories = (content, configDirectory) => {
6535
6636
  WEBPACK_PATH_CALL_PATTERN.lastIndex = 0;
6536
6637
  while ((pathCallMatch = WEBPACK_PATH_CALL_PATTERN.exec(modulesBlock)) !== null) moduleDirectories.push((0, node_path.resolve)(configDirectory, ...extractQuotedSegments(pathCallMatch[1])));
6537
6638
  let stringMatch;
6538
- WEBPACK_STRING_LITERAL_PATTERN.lastIndex = 0;
6539
- while ((stringMatch = WEBPACK_STRING_LITERAL_PATTERN.exec(modulesBlock)) !== null) {
6639
+ STRING_LITERAL_PATTERN.lastIndex = 0;
6640
+ while ((stringMatch = STRING_LITERAL_PATTERN.exec(modulesBlock)) !== null) {
6540
6641
  const moduleDirectory = stringMatch[1];
6541
6642
  if (moduleDirectory === "node_modules") continue;
6542
- moduleDirectories.push(resolveWebpackPathValue(moduleDirectory, configDirectory));
6643
+ moduleDirectories.push(resolveConfigPathValue(moduleDirectory, configDirectory));
6543
6644
  }
6544
6645
  }
6545
6646
  return [...new Set(moduleDirectories)];
6546
6647
  };
6547
- const loadWebpackResolverConfigs = (rootDir) => {
6548
- const configPaths = fast_glob.default.sync(WEBPACK_CONFIG_GLOBS, {
6648
+ const isJestConfigPath = (configPath) => /(?:^|[\\/])jest\.config\.[^\\/]+$/.test(configPath);
6649
+ const isWebpackConfigPath = (configPath) => /webpack/.test(configPath);
6650
+ const extractPackageJsonJestAliases = (rootDir) => {
6651
+ try {
6652
+ const moduleNameMapper = JSON.parse(cachedReadFileSync((0, node_path.join)(rootDir, "package.json")))?.jest?.moduleNameMapper;
6653
+ if (!moduleNameMapper || typeof moduleNameMapper !== "object") return [];
6654
+ const aliases = [];
6655
+ for (const [pattern, target] of Object.entries(moduleNameMapper)) {
6656
+ if (typeof target !== "string") continue;
6657
+ const alias = compileJestModuleNameMapperAlias(pattern, target, rootDir);
6658
+ if (alias) aliases.push(alias);
6659
+ }
6660
+ return aliases;
6661
+ } catch {
6662
+ return [];
6663
+ }
6664
+ };
6665
+ const loadBundlerAliasConfigs = (rootDir) => {
6666
+ const configPaths = fast_glob.default.sync([
6667
+ ...WEBPACK_CONFIG_GLOBS,
6668
+ ...VITE_CONFIG_GLOBS,
6669
+ ...BABEL_CONFIG_GLOBS,
6670
+ ...JEST_CONFIG_GLOBS
6671
+ ], {
6549
6672
  cwd: rootDir,
6550
6673
  absolute: true,
6551
6674
  onlyFiles: true,
@@ -6560,17 +6683,24 @@ const loadWebpackResolverConfigs = (rootDir) => {
6560
6683
  for (const configPath of configPaths) try {
6561
6684
  const content = cachedReadFileSync(configPath);
6562
6685
  const configDirectory = (0, node_path.dirname)(configPath);
6563
- const aliases = extractWebpackAliases(content, configDirectory);
6564
- const moduleDirectories = extractWebpackModuleDirectories(content, configDirectory);
6686
+ const aliases = extractBundlerAliases(content, configDirectory);
6687
+ if (isJestConfigPath(configPath)) aliases.push(...extractJestModuleNameMapperAliases(content, configDirectory));
6688
+ const moduleDirectories = isWebpackConfigPath(configPath) ? extractWebpackModuleDirectories(content, configDirectory) : [];
6565
6689
  if (aliases.length === 0 && moduleDirectories.length === 0) continue;
6566
6690
  configs.push({
6567
- scopeDirectory: findWebpackConfigScope(configPath, rootDir),
6691
+ scopeDirectory: findConfigScope(configPath, rootDir),
6568
6692
  aliases,
6569
6693
  moduleDirectories
6570
6694
  });
6571
6695
  } catch {
6572
6696
  continue;
6573
6697
  }
6698
+ const packageJsonJestAliases = extractPackageJsonJestAliases(rootDir);
6699
+ if (packageJsonJestAliases.length > 0) configs.push({
6700
+ scopeDirectory: (0, node_path.resolve)(rootDir),
6701
+ aliases: packageJsonJestAliases,
6702
+ moduleDirectories: []
6703
+ });
6574
6704
  return configs;
6575
6705
  };
6576
6706
  const createResolver = (config, workspacePackages = [], options = {}) => {
@@ -6609,7 +6739,36 @@ const createResolver = (config, workspacePackages = [], options = {}) => {
6609
6739
  };
6610
6740
  const workspaceNameToDirectory = /* @__PURE__ */ new Map();
6611
6741
  for (const workspacePackage of workspacePackages) workspaceNameToDirectory.set(workspacePackage.name, workspacePackage.directory);
6612
- const webpackResolverConfigs = (options.monorepoRoot && options.monorepoRoot !== config.rootDir ? [config.rootDir, options.monorepoRoot] : [config.rootDir]).flatMap(loadWebpackResolverConfigs).sort((leftConfig, rightConfig) => rightConfig.scopeDirectory.length - leftConfig.scopeDirectory.length);
6742
+ const structuralAliasToDirectory = /* @__PURE__ */ new Map();
6743
+ const workspaceScopes = /* @__PURE__ */ new Set();
6744
+ for (const workspacePackage of workspacePackages) {
6745
+ if (!workspacePackage.name.startsWith("@")) continue;
6746
+ const slashIndex = workspacePackage.name.indexOf("/");
6747
+ if (slashIndex !== -1) workspaceScopes.add(workspacePackage.name.slice(0, slashIndex));
6748
+ }
6749
+ if (workspaceScopes.size > 0) {
6750
+ const ambiguousStructuralKeys = /* @__PURE__ */ new Set();
6751
+ const registerStructuralAlias = (aliasKey, directory) => {
6752
+ if (workspaceNameToDirectory.has(aliasKey)) return;
6753
+ const existing = structuralAliasToDirectory.get(aliasKey);
6754
+ if (existing !== void 0 && existing !== directory) {
6755
+ ambiguousStructuralKeys.add(aliasKey);
6756
+ return;
6757
+ }
6758
+ structuralAliasToDirectory.set(aliasKey, directory);
6759
+ };
6760
+ for (const workspacePackage of workspacePackages) {
6761
+ const directoryBasename = (0, node_path.basename)(workspacePackage.directory);
6762
+ const slashIndex = workspacePackage.name.indexOf("/");
6763
+ const unscopedName = workspacePackage.name.startsWith("@") && slashIndex !== -1 ? workspacePackage.name.slice(slashIndex + 1) : workspacePackage.name;
6764
+ for (const scope of workspaceScopes) {
6765
+ registerStructuralAlias(`${scope}/${directoryBasename}`, workspacePackage.directory);
6766
+ if (unscopedName && unscopedName !== directoryBasename) registerStructuralAlias(`${scope}/${unscopedName}`, workspacePackage.directory);
6767
+ }
6768
+ }
6769
+ for (const ambiguousKey of ambiguousStructuralKeys) structuralAliasToDirectory.delete(ambiguousKey);
6770
+ }
6771
+ const bundlerAliasConfigs = (options.monorepoRoot && options.monorepoRoot !== config.rootDir ? [config.rootDir, options.monorepoRoot] : [config.rootDir]).flatMap(loadBundlerAliasConfigs).sort((leftConfig, rightConfig) => rightConfig.scopeDirectory.length - leftConfig.scopeDirectory.length);
6613
6772
  let rootTsconfigPath;
6614
6773
  if (config.tsConfigPath) rootTsconfigPath = (0, node_path.resolve)(config.rootDir, config.tsConfigPath);
6615
6774
  else {
@@ -6627,6 +6786,7 @@ const createResolver = (config, workspacePackages = [], options = {}) => {
6627
6786
  }
6628
6787
  const tsconfigPathCache = /* @__PURE__ */ new Map();
6629
6788
  const tsconfigPathAliasCache = /* @__PURE__ */ new Map();
6789
+ const tsconfigCompiledAliasCache = /* @__PURE__ */ new Map();
6630
6790
  const findTsconfigForFile = (filePath) => {
6631
6791
  const fileDir = (0, node_path.dirname)(filePath);
6632
6792
  const cached = tsconfigPathCache.get(fileDir);
@@ -6773,64 +6933,127 @@ const createResolver = (config, workspacePackages = [], options = {}) => {
6773
6933
  tsconfigPathAliasCache.set(tsconfigFile, aliasMap);
6774
6934
  return aliasMap;
6775
6935
  };
6936
+ const getCompiledPathAliases = (tsconfigFile) => {
6937
+ const cached = tsconfigCompiledAliasCache.get(tsconfigFile);
6938
+ if (cached) return cached;
6939
+ const compiled = compilePathMappings(getPathAliases(tsconfigFile));
6940
+ tsconfigCompiledAliasCache.set(tsconfigFile, compiled);
6941
+ return compiled;
6942
+ };
6776
6943
  const tryResolveViaPathAlias = (specifier, fromFile) => {
6777
6944
  const tsconfigFile = findTsconfigForFile(fromFile);
6778
6945
  if (!tsconfigFile) return void 0;
6779
- const aliases = getPathAliases(tsconfigFile);
6780
- for (const [pattern, targetPatterns] of aliases) {
6781
- const wildcardIndex = pattern.indexOf("*");
6782
- if (wildcardIndex === -1) {
6783
- if (specifier === pattern) for (const targetPattern of targetPatterns) {
6784
- const candidate = targetPattern.replace("*", "");
6785
- if (existsAsFile(candidate)) return candidate;
6786
- for (const ext of RESOLVER_EXTENSIONS) if (cachedExistsSync(candidate + ext)) return candidate + ext;
6787
- const indexCandidate = (0, node_path.join)(candidate, "index");
6788
- for (const ext of RESOLVER_EXTENSIONS) if (cachedExistsSync(indexCandidate + ext)) return indexCandidate + ext;
6789
- }
6790
- continue;
6791
- }
6792
- const prefix = pattern.slice(0, wildcardIndex);
6793
- const suffix = pattern.slice(wildcardIndex + 1);
6794
- if (!specifier.startsWith(prefix) || !specifier.endsWith(suffix)) continue;
6795
- const matchedWildcard = specifier.slice(prefix.length, specifier.length - suffix.length);
6796
- for (const targetPattern of targetPatterns) {
6797
- const resolvedTarget = targetPattern.replace("*", matchedWildcard);
6798
- if (existsAsFile(resolvedTarget)) return resolvedTarget;
6799
- for (const ext of RESOLVER_EXTENSIONS) if (cachedExistsSync(resolvedTarget + ext)) return resolvedTarget + ext;
6800
- const strippedTarget = resolvedTarget.replace(/\.[cm]?js$/, "");
6801
- if (strippedTarget !== resolvedTarget) {
6802
- for (const ext of RESOLVER_EXTENSIONS) if (cachedExistsSync(strippedTarget + ext)) return strippedTarget + ext;
6803
- }
6804
- const indexCandidate = (0, node_path.join)(resolvedTarget, "index");
6805
- for (const ext of RESOLVER_EXTENSIONS) if (cachedExistsSync(indexCandidate + ext)) return indexCandidate + ext;
6806
- }
6807
- }
6946
+ return matchCompiledMapping(specifier, getCompiledPathAliases(tsconfigFile));
6808
6947
  };
6809
6948
  const tryResolveFromDirectory = (directory, specifier) => {
6810
6949
  const candidatePath = resolvePathWithExtensionFallback((0, node_path.resolve)(directory, specifier));
6811
6950
  if (existsAsFile(candidatePath)) return candidatePath;
6812
6951
  };
6813
- const tryResolveViaWebpackConfig = (specifier, fromFile) => {
6814
- if (webpackResolverConfigs.length === 0) return void 0;
6952
+ const tryResolveViaBundlerAlias = (specifier, fromFile) => {
6953
+ if (bundlerAliasConfigs.length === 0) return void 0;
6815
6954
  if (!isBareSpecifier(specifier)) return void 0;
6816
- for (const webpackConfig of webpackResolverConfigs) {
6817
- if (!isInsideDirectory(fromFile, webpackConfig.scopeDirectory)) continue;
6818
- for (const alias of webpackConfig.aliases) {
6955
+ for (const bundlerConfig of bundlerAliasConfigs) {
6956
+ if (!isInsideDirectory(fromFile, bundlerConfig.scopeDirectory)) continue;
6957
+ for (const alias of bundlerConfig.aliases) {
6819
6958
  if (alias.isExact && specifier !== alias.name) continue;
6820
6959
  const suffix = specifier === alias.name ? "" : specifier.startsWith(`${alias.name}/`) ? specifier.slice(alias.name.length + 1) : void 0;
6821
6960
  if (suffix === void 0) continue;
6822
6961
  const aliasCandidate = tryResolveFromDirectory(alias.targetDirectory, suffix);
6823
6962
  if (aliasCandidate) return aliasCandidate;
6824
6963
  }
6825
- for (const moduleDirectory of webpackConfig.moduleDirectories) {
6964
+ for (const moduleDirectory of bundlerConfig.moduleDirectories) {
6826
6965
  const moduleCandidate = tryResolveFromDirectory(moduleDirectory, specifier);
6827
6966
  if (moduleCandidate) return moduleCandidate;
6828
6967
  }
6829
6968
  }
6830
6969
  };
6970
+ const compiledConfigPaths = config.paths ? compilePathMappings(Object.entries(config.paths).map(([pattern, targets]) => [pattern, targets.map((target) => (0, node_path.resolve)(config.rootDir, target))])) : [];
6971
+ const tryResolveViaConfigPaths = (specifier) => compiledConfigPaths.length === 0 ? void 0 : matchCompiledMapping(specifier, compiledConfigPaths);
6972
+ const resolveWorkspaceSubpath = (workspaceDirectory, subpath) => {
6973
+ const workspacePackageJsonPath = (0, node_path.join)(workspaceDirectory, "package.json");
6974
+ try {
6975
+ const workspacePackageContent = cachedReadFileSync(workspacePackageJsonPath);
6976
+ const workspacePackageJson = JSON.parse(workspacePackageContent);
6977
+ let resolvedEntryPath;
6978
+ if (subpath && workspacePackageJson.exports) {
6979
+ const exportKey = `./${subpath}`;
6980
+ const exportValue = workspacePackageJson.exports[exportKey];
6981
+ if (typeof exportValue === "string") {
6982
+ const candidatePath = resolvePathWithExtensionFallback((0, node_path.resolve)(workspaceDirectory, exportValue));
6983
+ resolvedEntryPath = existsAsFile(candidatePath) ? candidatePath : trySourceFallback(candidatePath);
6984
+ } else if (typeof exportValue === "object" && exportValue !== null) {
6985
+ const conditionValue = exportValue.import ?? exportValue.require ?? exportValue.default ?? exportValue.types;
6986
+ if (typeof conditionValue === "string") {
6987
+ const candidatePath = resolvePathWithExtensionFallback((0, node_path.resolve)(workspaceDirectory, conditionValue));
6988
+ resolvedEntryPath = existsAsFile(candidatePath) ? candidatePath : trySourceFallback(candidatePath);
6989
+ }
6990
+ }
6991
+ if (!resolvedEntryPath) for (const [wildcardPattern, wildcardTarget] of Object.entries(workspacePackageJson.exports)) {
6992
+ if (typeof wildcardPattern !== "string" || !wildcardPattern.includes("*")) continue;
6993
+ const wildcardTargetRecord = typeof wildcardTarget === "object" && wildcardTarget !== null ? wildcardTarget : void 0;
6994
+ const wildcardTargetValue = typeof wildcardTarget === "string" ? wildcardTarget : wildcardTargetRecord ? String(wildcardTargetRecord["import"] ?? wildcardTargetRecord["require"] ?? wildcardTargetRecord["default"] ?? wildcardTargetRecord["types"] ?? "") : void 0;
6995
+ if (typeof wildcardTargetValue !== "string") continue;
6996
+ const wildcardPrefix = wildcardPattern.slice(0, wildcardPattern.indexOf("*"));
6997
+ const wildcardSuffix = wildcardPattern.slice(wildcardPattern.indexOf("*") + 1);
6998
+ if (exportKey.startsWith(wildcardPrefix) && exportKey.endsWith(wildcardSuffix)) {
6999
+ const matchedSegment = exportKey.slice(wildcardPrefix.length, exportKey.length - wildcardSuffix.length || void 0);
7000
+ const candidatePath = resolvePathWithExtensionFallback((0, node_path.resolve)(workspaceDirectory, wildcardTargetValue.replace("*", matchedSegment)));
7001
+ resolvedEntryPath = existsAsFile(candidatePath) ? candidatePath : trySourceFallback(candidatePath);
7002
+ break;
7003
+ }
7004
+ }
7005
+ }
7006
+ if (subpath && !resolvedEntryPath) {
7007
+ const subpathCandidates = [(0, node_path.resolve)(workspaceDirectory, subpath), (0, node_path.resolve)(workspaceDirectory, "src", subpath)];
7008
+ for (const directSubpath of subpathCandidates) {
7009
+ for (const candidateExtension of RESOLVER_EXTENSIONS) {
7010
+ const candidate = directSubpath + candidateExtension;
7011
+ if (cachedExistsSync(candidate)) {
7012
+ resolvedEntryPath = candidate;
7013
+ break;
7014
+ }
7015
+ }
7016
+ if (resolvedEntryPath) break;
7017
+ for (const candidateExtension of RESOLVER_EXTENSIONS) {
7018
+ const indexCandidate = (0, node_path.join)(directSubpath, `index${candidateExtension}`);
7019
+ if (cachedExistsSync(indexCandidate)) {
7020
+ resolvedEntryPath = indexCandidate;
7021
+ break;
7022
+ }
7023
+ }
7024
+ if (resolvedEntryPath) break;
7025
+ }
7026
+ }
7027
+ if (!subpath) {
7028
+ const mainField = workspacePackageJson.main ?? workspacePackageJson.module;
7029
+ if (typeof mainField === "string") resolvedEntryPath = (0, node_path.resolve)(workspaceDirectory, mainField);
7030
+ if (!resolvedEntryPath && workspacePackageJson.exports?.["."]) {
7031
+ const dotExport = workspacePackageJson.exports["."];
7032
+ if (typeof dotExport === "string") resolvedEntryPath = (0, node_path.resolve)(workspaceDirectory, dotExport);
7033
+ else if (typeof dotExport === "object" && dotExport !== null) {
7034
+ const conditionValue = dotExport.import ?? dotExport.require ?? dotExport.default ?? dotExport.types;
7035
+ if (typeof conditionValue === "string") resolvedEntryPath = (0, node_path.resolve)(workspaceDirectory, conditionValue);
7036
+ }
7037
+ }
7038
+ }
7039
+ if (resolvedEntryPath) {
7040
+ const finalPath = resolveSourcePath(resolvedEntryPath, workspaceDirectory) ?? resolvedEntryPath;
7041
+ if (cachedExistsSync(finalPath)) return finalPath;
7042
+ const sourceFallbackPath = trySourceFallback(resolvedEntryPath);
7043
+ if (sourceFallbackPath) return sourceFallbackPath;
7044
+ }
7045
+ } catch {}
7046
+ };
7047
+ const tryResolveViaWorkspaceStructure = (specifier) => {
7048
+ if (structuralAliasToDirectory.size === 0) return void 0;
7049
+ if (!isBareSpecifier(specifier)) return void 0;
7050
+ const packageKey = extractPackageNameFromSpecifier(specifier);
7051
+ const directory = structuralAliasToDirectory.get(packageKey);
7052
+ if (!directory) return void 0;
7053
+ return resolveWorkspaceSubpath(directory, specifier.length > packageKey.length ? specifier.slice(packageKey.length + 1) : "");
7054
+ };
6831
7055
  const resolveModule = (specifier, fromFile) => {
6832
- const queryIndex = specifier.indexOf("?");
6833
- const cleanedSpecifier = queryIndex !== -1 ? specifier.slice(0, queryIndex) : specifier;
7056
+ const cleanedSpecifier = sanitizeImportSpecifier(specifier);
6834
7057
  const fromDir = (0, node_path.dirname)(fromFile);
6835
7058
  const cacheKey = `${fromDir}::${cleanedSpecifier}`;
6836
7059
  const cached = resolveResultCache.get(cacheKey);
@@ -6860,96 +7083,16 @@ const createResolver = (config, workspacePackages = [], options = {}) => {
6860
7083
  const packageName = extractPackageNameFromSpecifier(cleanedSpecifier);
6861
7084
  const workspaceDirectory = workspaceNameToDirectory.get(packageName);
6862
7085
  if (workspaceDirectory) {
6863
- const subpath = cleanedSpecifier.slice(packageName.length + 1);
6864
- const workspacePackageJsonPath = (0, node_path.join)(workspaceDirectory, "package.json");
6865
- try {
6866
- const workspacePackageContent = cachedReadFileSync(workspacePackageJsonPath);
6867
- const workspacePackageJson = JSON.parse(workspacePackageContent);
6868
- let resolvedEntryPath;
6869
- if (subpath && workspacePackageJson.exports) {
6870
- const exportKey = `./${subpath}`;
6871
- const exportValue = workspacePackageJson.exports[exportKey];
6872
- if (typeof exportValue === "string") {
6873
- const candidatePath = resolvePathWithExtensionFallback((0, node_path.resolve)(workspaceDirectory, exportValue));
6874
- resolvedEntryPath = existsAsFile(candidatePath) ? candidatePath : trySourceFallback(candidatePath);
6875
- } else if (typeof exportValue === "object" && exportValue !== null) {
6876
- const conditionValue = exportValue.import ?? exportValue.require ?? exportValue.default ?? exportValue.types;
6877
- if (typeof conditionValue === "string") {
6878
- const candidatePath = resolvePathWithExtensionFallback((0, node_path.resolve)(workspaceDirectory, conditionValue));
6879
- resolvedEntryPath = existsAsFile(candidatePath) ? candidatePath : trySourceFallback(candidatePath);
6880
- }
6881
- }
6882
- if (!resolvedEntryPath) for (const [wildcardPattern, wildcardTarget] of Object.entries(workspacePackageJson.exports)) {
6883
- if (typeof wildcardPattern !== "string" || !wildcardPattern.includes("*")) continue;
6884
- const wildcardTargetRecord = typeof wildcardTarget === "object" && wildcardTarget !== null ? wildcardTarget : void 0;
6885
- const wildcardTargetValue = typeof wildcardTarget === "string" ? wildcardTarget : wildcardTargetRecord ? String(wildcardTargetRecord["import"] ?? wildcardTargetRecord["require"] ?? wildcardTargetRecord["default"] ?? wildcardTargetRecord["types"] ?? "") : void 0;
6886
- if (typeof wildcardTargetValue !== "string") continue;
6887
- const wildcardPrefix = wildcardPattern.slice(0, wildcardPattern.indexOf("*"));
6888
- const wildcardSuffix = wildcardPattern.slice(wildcardPattern.indexOf("*") + 1);
6889
- if (exportKey.startsWith(wildcardPrefix) && exportKey.endsWith(wildcardSuffix)) {
6890
- const matchedSegment = exportKey.slice(wildcardPrefix.length, exportKey.length - wildcardSuffix.length || void 0);
6891
- const candidatePath = resolvePathWithExtensionFallback((0, node_path.resolve)(workspaceDirectory, wildcardTargetValue.replace("*", matchedSegment)));
6892
- resolvedEntryPath = existsAsFile(candidatePath) ? candidatePath : trySourceFallback(candidatePath);
6893
- break;
6894
- }
6895
- }
6896
- }
6897
- if (subpath && !resolvedEntryPath) {
6898
- const subpathCandidates = [(0, node_path.resolve)(workspaceDirectory, subpath), (0, node_path.resolve)(workspaceDirectory, "src", subpath)];
6899
- for (const directSubpath of subpathCandidates) {
6900
- for (const candidateExtension of RESOLVER_EXTENSIONS) {
6901
- const candidate = directSubpath + candidateExtension;
6902
- if (cachedExistsSync(candidate)) {
6903
- resolvedEntryPath = candidate;
6904
- break;
6905
- }
6906
- }
6907
- if (resolvedEntryPath) break;
6908
- for (const candidateExtension of RESOLVER_EXTENSIONS) {
6909
- const indexCandidate = (0, node_path.join)(directSubpath, `index${candidateExtension}`);
6910
- if (cachedExistsSync(indexCandidate)) {
6911
- resolvedEntryPath = indexCandidate;
6912
- break;
6913
- }
6914
- }
6915
- if (resolvedEntryPath) break;
6916
- }
6917
- }
6918
- if (!subpath) {
6919
- const mainField = workspacePackageJson.main ?? workspacePackageJson.module;
6920
- if (typeof mainField === "string") resolvedEntryPath = (0, node_path.resolve)(workspaceDirectory, mainField);
6921
- if (!resolvedEntryPath && workspacePackageJson.exports?.["."]) {
6922
- const dotExport = workspacePackageJson.exports["."];
6923
- if (typeof dotExport === "string") resolvedEntryPath = (0, node_path.resolve)(workspaceDirectory, dotExport);
6924
- else if (typeof dotExport === "object" && dotExport !== null) {
6925
- const conditionValue = dotExport.import ?? dotExport.require ?? dotExport.default ?? dotExport.types;
6926
- if (typeof conditionValue === "string") resolvedEntryPath = (0, node_path.resolve)(workspaceDirectory, conditionValue);
6927
- }
6928
- }
6929
- }
6930
- if (resolvedEntryPath) {
6931
- const finalPath = resolveSourcePath(resolvedEntryPath, workspaceDirectory) ?? resolvedEntryPath;
6932
- if (cachedExistsSync(finalPath)) {
6933
- const resolvedResult = {
6934
- resolvedPath: finalPath,
6935
- isExternal: false,
6936
- packageName: void 0
6937
- };
6938
- resolveResultCache.set(cacheKey, resolvedResult);
6939
- return resolvedResult;
6940
- }
6941
- const sourceFallbackPath = trySourceFallback(resolvedEntryPath);
6942
- if (sourceFallbackPath) {
6943
- const resolvedResult = {
6944
- resolvedPath: sourceFallbackPath,
6945
- isExternal: false,
6946
- packageName: void 0
6947
- };
6948
- resolveResultCache.set(cacheKey, resolvedResult);
6949
- return resolvedResult;
6950
- }
6951
- }
6952
- } catch {}
7086
+ const resolvedWorkspacePath = resolveWorkspaceSubpath(workspaceDirectory, cleanedSpecifier.slice(packageName.length + 1));
7087
+ if (resolvedWorkspacePath) {
7088
+ const resolvedResult = {
7089
+ resolvedPath: resolvedWorkspacePath,
7090
+ isExternal: false,
7091
+ packageName: void 0
7092
+ };
7093
+ resolveResultCache.set(cacheKey, resolvedResult);
7094
+ return resolvedResult;
7095
+ }
6953
7096
  }
6954
7097
  }
6955
7098
  const tsconfigForFile = findTsconfigForFile(fromFile);
@@ -6992,10 +7135,30 @@ const createResolver = (config, workspacePackages = [], options = {}) => {
6992
7135
  resolveResultCache.set(cacheKey, resolvedResult);
6993
7136
  return resolvedResult;
6994
7137
  }
6995
- const webpackResolved = tryResolveViaWebpackConfig(cleanedSpecifier, fromFile);
6996
- if (webpackResolved) {
7138
+ const configPathResolved = tryResolveViaConfigPaths(cleanedSpecifier);
7139
+ if (configPathResolved) {
7140
+ const resolvedResult = {
7141
+ resolvedPath: configPathResolved,
7142
+ isExternal: false,
7143
+ packageName: void 0
7144
+ };
7145
+ resolveResultCache.set(cacheKey, resolvedResult);
7146
+ return resolvedResult;
7147
+ }
7148
+ const bundlerAliasResolved = tryResolveViaBundlerAlias(cleanedSpecifier, fromFile);
7149
+ if (bundlerAliasResolved) {
6997
7150
  const resolvedResult = {
6998
- resolvedPath: webpackResolved,
7151
+ resolvedPath: bundlerAliasResolved,
7152
+ isExternal: false,
7153
+ packageName: void 0
7154
+ };
7155
+ resolveResultCache.set(cacheKey, resolvedResult);
7156
+ return resolvedResult;
7157
+ }
7158
+ const structuralResolved = tryResolveViaWorkspaceStructure(cleanedSpecifier);
7159
+ if (structuralResolved) {
7160
+ const resolvedResult = {
7161
+ resolvedPath: structuralResolved,
6999
7162
  isExternal: false,
7000
7163
  packageName: void 0
7001
7164
  };
@@ -7177,7 +7340,8 @@ const buildDependencyGraph = (inputs) => {
7177
7340
  isTestEntry: input.isTestEntry,
7178
7341
  isReachable: false,
7179
7342
  isDeclarationFile: input.fileId.path.endsWith(".d.ts") || input.fileId.path.endsWith(".d.mts") || input.fileId.path.endsWith(".d.cts"),
7180
- isConfigFile: isConfigFile(input.fileId.path)
7343
+ isConfigFile: isConfigFile(input.fileId.path),
7344
+ isGitIgnored: input.isGitIgnored
7181
7345
  }));
7182
7346
  const edges = [];
7183
7347
  const reverseEdges = /* @__PURE__ */ new Map();
@@ -7514,6 +7678,7 @@ const detectOrphanFiles = (graph) => {
7514
7678
  if (module.isEntryPoint) continue;
7515
7679
  if (module.isDeclarationFile) continue;
7516
7680
  if (module.isConfigFile) continue;
7681
+ if (module.isGitIgnored) continue;
7517
7682
  if (hasExcludedExtension(module.fileId.path)) continue;
7518
7683
  if (isExcludedByPattern(module.fileId.path)) continue;
7519
7684
  if (isOpaqueToAnalysis(module)) continue;
@@ -7548,6 +7713,7 @@ const detectDeadExports = (graph, config) => {
7548
7713
  for (const module of graph.modules) {
7549
7714
  if (!module.isReachable) continue;
7550
7715
  if (module.isDeclarationFile) continue;
7716
+ if (module.isGitIgnored) continue;
7551
7717
  if (module.isEntryPoint && !config.includeEntryExports) continue;
7552
7718
  const defaultExportLinkedNames = /* @__PURE__ */ new Set();
7553
7719
  for (const exportInfo of module.exports) if (exportInfo.isDefault && exportInfo.defaultExportLocalName && usageMap.has(`${module.fileId.path}::default`)) defaultExportLinkedNames.add(exportInfo.defaultExportLocalName);
@@ -12482,6 +12648,64 @@ const generateReport = (graph, config) => {
12482
12648
  };
12483
12649
  };
12484
12650
 
12651
+ //#endregion
12652
+ //#region src/utils/collect-git-ignored-paths.ts
12653
+ /**
12654
+ * Returns the subset of `candidatePaths` that git considers ignored.
12655
+ *
12656
+ * `--no-index` is load-bearing: without it `git check-ignore` stays silent for
12657
+ * any path already tracked in the index, so generated files that were committed
12658
+ * once (then later gitignored) would not be reported. We want the ignore *rules*
12659
+ * to decide, independent of tracking state.
12660
+ *
12661
+ * `core.excludesFile=<devNull>` scopes the result to the analyzed project's own
12662
+ * ignore rules: a developer's personal global gitignore must not change which
12663
+ * files deslop reports, otherwise the same project yields different findings on
12664
+ * different machines.
12665
+ *
12666
+ * `gitUnavailable` is true only when the `git` binary could not be launched
12667
+ * (e.g. not installed → `ENOENT`). A non-git directory is normal: git exits 128
12668
+ * and often closes stdin before reading it, which surfaces as an `EPIPE` on the
12669
+ * input write — that is reported as available-but-empty, not a failure. Every
12670
+ * failure still degrades to an empty set so callers never crash. Exit status 1
12671
+ * means "no matches", not an error.
12672
+ */
12673
+ const collectGitIgnoredPaths = (rootDirectory, candidatePaths) => {
12674
+ if (candidatePaths.length === 0) return {
12675
+ ignoredPaths: /* @__PURE__ */ new Set(),
12676
+ gitUnavailable: false
12677
+ };
12678
+ const result = (0, node_child_process.spawnSync)("git", [
12679
+ "-c",
12680
+ `core.excludesFile=${node_os.devNull}`,
12681
+ "check-ignore",
12682
+ "--no-index",
12683
+ "--stdin",
12684
+ "-z"
12685
+ ], {
12686
+ cwd: rootDirectory,
12687
+ input: candidatePaths.join("\0"),
12688
+ encoding: "utf-8",
12689
+ maxBuffer: GIT_CHECK_IGNORE_MAX_BUFFER_BYTES
12690
+ });
12691
+ if (result.error) {
12692
+ const gitBinaryMissing = "code" in result.error && result.error.code === "ENOENT";
12693
+ return {
12694
+ ignoredPaths: /* @__PURE__ */ new Set(),
12695
+ gitUnavailable: gitBinaryMissing
12696
+ };
12697
+ }
12698
+ if (result.status === null || result.status > 1) return {
12699
+ ignoredPaths: /* @__PURE__ */ new Set(),
12700
+ gitUnavailable: false
12701
+ };
12702
+ const ignoredPaths = result.stdout.split("\0").filter((entry) => entry.length > 0);
12703
+ return {
12704
+ ignoredPaths: new Set(ignoredPaths),
12705
+ gitUnavailable: false
12706
+ };
12707
+ };
12708
+
12485
12709
  //#endregion
12486
12710
  //#region src/index.ts
12487
12711
  const STYLE_EXTENSIONS = [".css", ".scss"];
@@ -12617,6 +12841,7 @@ const defineConfig = (options) => ({
12617
12841
  ignorePatterns: options.ignorePatterns ?? [],
12618
12842
  includeExtensions: options.includeExtensions ?? DEFAULT_EXTENSIONS,
12619
12843
  tsConfigPath: options.tsConfigPath,
12844
+ paths: options.paths,
12620
12845
  reportTypes: options.reportTypes ?? false,
12621
12846
  includeEntryExports: options.includeEntryExports ?? false,
12622
12847
  reportRedundancy: options.reportRedundancy ?? true,
@@ -12767,6 +12992,14 @@ const analyze = async (config) => {
12767
12992
  const productionEntrySet = new Set(discoveredEntries.productionEntries);
12768
12993
  const testEntrySet = new Set(discoveredEntries.testEntries);
12769
12994
  const alwaysUsedFileSet = new Set(discoveredEntries.alwaysUsedFiles);
12995
+ const gitIgnoreResult = collectGitIgnoredPaths((0, node_path.resolve)(config.rootDir), files.map((file) => file.path));
12996
+ const gitIgnoredFileSet = gitIgnoreResult.ignoredPaths;
12997
+ if (gitIgnoreResult.gitUnavailable) setupErrors.push(new WorkspaceError({
12998
+ code: "gitignore-check-failed",
12999
+ severity: "info",
13000
+ message: "git unavailable — .gitignore filtering skipped",
13001
+ path: config.rootDir
13002
+ }));
12770
13003
  let hasReactNative = false;
12771
13004
  try {
12772
13005
  hasReactNative = detectReactNative(config.rootDir, workspacePackages);
@@ -12855,7 +13088,8 @@ const analyze = async (config) => {
12855
13088
  parsed: parsedModule,
12856
13089
  resolvedImports: resolvedImportMap,
12857
13090
  isEntryPoint: isAlwaysUsed || productionEntrySet.has(file.path) || testEntrySet.has(file.path),
12858
- isTestEntry: testEntrySet.has(file.path)
13091
+ isTestEntry: testEntrySet.has(file.path),
13092
+ isGitIgnored: gitIgnoredFileSet.has(file.path)
12859
13093
  });
12860
13094
  }
12861
13095
  const discoveredFilePaths = new Set(files.map((file) => file.path));
@@ -12901,7 +13135,8 @@ const analyze = async (config) => {
12901
13135
  parsed: parsedStyleModule,
12902
13136
  resolvedImports: resolvedStyleImportMap,
12903
13137
  isEntryPoint: false,
12904
- isTestEntry: false
13138
+ isTestEntry: false,
13139
+ isGitIgnored: gitIgnoredFileSet.has(styleFilePath)
12905
13140
  });
12906
13141
  discoveredFilePaths.add(styleFilePath);
12907
13142
  nextFileIndex++;