@powerlines/nx 0.11.250 → 0.11.252

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 (57) hide show
  1. package/dist/src/base/base-executor.d.mts +1 -1
  2. package/dist/src/base/base-executor.d.ts +1 -1
  3. package/dist/src/base/base-executor.js +1 -1
  4. package/dist/src/base/base-executor.mjs +1 -1
  5. package/dist/src/base/index.d.mts +1 -1
  6. package/dist/src/base/index.d.ts +1 -1
  7. package/dist/src/base/index.js +1 -1
  8. package/dist/src/base/index.mjs +1 -1
  9. package/dist/src/{base-executor-BX0xduN1.mjs → base-executor-C6v5AHYW.mjs} +148 -86
  10. package/dist/src/base-executor-C6v5AHYW.mjs.map +1 -0
  11. package/dist/src/{base-executor-CsvdsKIS.d.mts → base-executor-CDMeDnfo.d.mts} +5 -1
  12. package/dist/src/base-executor-CDMeDnfo.d.mts.map +1 -0
  13. package/dist/src/{base-executor-C8b3Jrmp.js → base-executor-CYwhd1QJ.js} +147 -85
  14. package/dist/src/{base-executor-D0Q1wshU.d.ts → base-executor-CssolRCu.d.ts} +5 -1
  15. package/dist/src/base-executor-CssolRCu.d.ts.map +1 -0
  16. package/dist/src/{base-executor-C_eSw2CH.js → base-executor-DpQbYOg0.js} +147 -85
  17. package/dist/src/{base-executor-Cng3H0co.mjs → base-executor-DuE-P1yw.mjs} +148 -86
  18. package/dist/src/base-executor-DuE-P1yw.mjs.map +1 -0
  19. package/dist/src/base-executor.untyped-BOvdnsUw.d.mts +7 -0
  20. package/dist/src/base-executor.untyped-BOvdnsUw.d.mts.map +1 -0
  21. package/dist/src/base-executor.untyped-BVblCsuG.d.ts +7 -0
  22. package/dist/src/base-executor.untyped-BVblCsuG.d.ts.map +1 -0
  23. package/dist/src/executors/build/executor.d.mts +1 -1
  24. package/dist/src/executors/build/executor.d.ts +1 -1
  25. package/dist/src/executors/build/executor.js +1 -1
  26. package/dist/src/executors/build/executor.mjs +1 -1
  27. package/dist/src/executors/clean/executor.d.mts +1 -1
  28. package/dist/src/executors/clean/executor.d.ts +1 -1
  29. package/dist/src/executors/clean/executor.js +1 -1
  30. package/dist/src/executors/clean/executor.mjs +1 -1
  31. package/dist/src/executors/clean/untyped.d.ts +2 -2
  32. package/dist/src/executors/docs/executor.d.mts +1 -1
  33. package/dist/src/executors/docs/executor.d.ts +1 -1
  34. package/dist/src/executors/docs/executor.js +1 -1
  35. package/dist/src/executors/docs/executor.mjs +1 -1
  36. package/dist/src/executors/docs/untyped.d.mts +2 -2
  37. package/dist/src/executors/docs/untyped.d.ts +2 -2
  38. package/dist/src/executors/lint/executor.d.mts +1 -1
  39. package/dist/src/executors/lint/executor.d.ts +1 -1
  40. package/dist/src/executors/lint/executor.js +1 -1
  41. package/dist/src/executors/lint/executor.mjs +1 -1
  42. package/dist/src/executors/lint/untyped.d.mts +2 -2
  43. package/dist/src/executors/prepare/executor.d.mts +1 -1
  44. package/dist/src/executors/prepare/executor.d.ts +1 -1
  45. package/dist/src/executors/prepare/executor.js +1 -1
  46. package/dist/src/executors/prepare/executor.mjs +1 -1
  47. package/dist/src/executors/prepare/untyped.d.mts +2 -2
  48. package/dist/src/generators/sync/untyped.d.mts +2 -2
  49. package/dist/src/index.d.mts +1 -1
  50. package/dist/src/index.d.ts +1 -1
  51. package/dist/src/index.js +1 -1
  52. package/dist/src/index.mjs +1 -1
  53. package/package.json +16 -16
  54. package/dist/src/base-executor-BX0xduN1.mjs.map +0 -1
  55. package/dist/src/base-executor-Cng3H0co.mjs.map +0 -1
  56. package/dist/src/base-executor-CsvdsKIS.d.mts.map +0 -1
  57. package/dist/src/base-executor-D0Q1wshU.d.ts.map +0 -1
@@ -84,7 +84,7 @@ let node_path = require("node:path");
84
84
  require("unplugin");
85
85
 
86
86
  //#region ../powerlines/package.json
87
- var version = "0.40.8";
87
+ var version = "0.40.11";
88
88
 
89
89
  //#endregion
90
90
  //#region ../powerlines/src/typescript/ts-morph.ts
@@ -1826,6 +1826,24 @@ var VirtualStorageAdapter = class extends BaseStorageAdapter {
1826
1826
  }
1827
1827
  };
1828
1828
 
1829
+ //#endregion
1830
+ //#region ../powerlines/src/_internal/helpers/constants.ts
1831
+ const DEFAULT_EXTENSIONS = [
1832
+ "js",
1833
+ "ts",
1834
+ "cjs",
1835
+ "cts",
1836
+ "mjs",
1837
+ "mts",
1838
+ "tsx",
1839
+ "jsx",
1840
+ "json",
1841
+ "json5",
1842
+ "jsonc",
1843
+ "md",
1844
+ "mdx"
1845
+ ];
1846
+
1829
1847
  //#endregion
1830
1848
  //#region ../powerlines/src/_internal/vfs.ts
1831
1849
  function toFilePath(path) {
@@ -1982,6 +2000,113 @@ var VirtualFileSystem = class VirtualFileSystem {
1982
2000
  }));
1983
2001
  }
1984
2002
  /**
2003
+ * A helper function to resolve modules in the virtual file system (VFS).
2004
+ *
2005
+ * @remarks
2006
+ * This function can be used to resolve modules relative to the project root directory.
2007
+ *
2008
+ * @example
2009
+ * ```ts
2010
+ * const resolved = await context.resolvePath("some-module", "/path/to/importer");
2011
+ * ```
2012
+ *
2013
+ * @param id - The module to resolve.
2014
+ * @param importer - An optional path to the importer module.
2015
+ * @param options - Additional resolution options.
2016
+ * @returns A promise that resolves to the resolved module path.
2017
+ */
2018
+ #innerResolve = async (id, importer, options = {}) => {
2019
+ let path = id;
2020
+ if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
2021
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
2022
+ if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
2023
+ const resolverCacheKey = (0, __stryke_hash.murmurhash)({
2024
+ path: this.#normalizeId(path),
2025
+ importer,
2026
+ options
2027
+ });
2028
+ let result;
2029
+ if (!this.#context.config.skipCache) {
2030
+ result = this.resolverCache.get(resolverCacheKey);
2031
+ if (result) return result;
2032
+ }
2033
+ result = this.paths[this.#normalizeId(path)];
2034
+ if (!result) {
2035
+ const paths = options.paths ?? [];
2036
+ if (importer && !paths.includes(importer)) paths.push(importer);
2037
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
2038
+ paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
2039
+ paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
2040
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => (0, __stryke_path_append.appendPath)(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2041
+ for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
2042
+ const { relativeKey, adapter } = this.#getStorage(combination);
2043
+ if (await adapter.exists(relativeKey)) {
2044
+ result = combination;
2045
+ break;
2046
+ }
2047
+ }
2048
+ if (!result) try {
2049
+ result = await (0, __stryke_fs_resolve.resolve)(path, {
2050
+ ...options,
2051
+ paths
2052
+ });
2053
+ } catch {}
2054
+ }
2055
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
2056
+ return result;
2057
+ };
2058
+ /**
2059
+ * A synchronous helper function to resolve modules using the Jiti resolver
2060
+ *
2061
+ * @remarks
2062
+ * This function can be used to resolve modules relative to the project root directory.
2063
+ *
2064
+ * @example
2065
+ * ```ts
2066
+ * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
2067
+ * ```
2068
+ *
2069
+ * @param id - The module to resolve.
2070
+ * @param importer - An optional path to the importer module.
2071
+ * @param options - Additional resolution options.
2072
+ * @returns The resolved module path.
2073
+ */
2074
+ #innerResolveSync = (id, importer, options = {}) => {
2075
+ let path = id;
2076
+ if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
2077
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
2078
+ if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
2079
+ let result;
2080
+ if (!this.#context.config.skipCache) {
2081
+ result = this.resolverCache.get(this.#normalizeId(path));
2082
+ if (result) return result;
2083
+ }
2084
+ result = this.paths[this.#normalizeId(path)];
2085
+ if (!result) {
2086
+ const paths = options.paths ?? [];
2087
+ if (importer && !paths.includes(importer)) paths.push(importer);
2088
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
2089
+ paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
2090
+ paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
2091
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => (0, __stryke_path_append.appendPath)(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2092
+ for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
2093
+ const { relativeKey, adapter } = this.#getStorage(combination);
2094
+ if (adapter.existsSync(relativeKey)) {
2095
+ result = combination;
2096
+ break;
2097
+ }
2098
+ }
2099
+ if (!result) try {
2100
+ result = (0, __stryke_fs_resolve.resolveSync)(path, {
2101
+ ...options,
2102
+ paths
2103
+ });
2104
+ } catch {}
2105
+ }
2106
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
2107
+ return result;
2108
+ };
2109
+ /**
1985
2110
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
1986
2111
  *
1987
2112
  * @param context - The context of the virtual file system, typically containing options and logging functions.
@@ -2453,7 +2578,7 @@ var VirtualFileSystem = class VirtualFileSystem {
2453
2578
  * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
2454
2579
  */
2455
2580
  async read(path) {
2456
- const filePath = await this.resolve(path);
2581
+ const filePath = await this.resolve(path, void 0, { isFile: true });
2457
2582
  if (!filePath || !this.existsSync(filePath)) return;
2458
2583
  const { adapter } = this.#getStorage(filePath);
2459
2584
  this.#log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -2466,7 +2591,7 @@ var VirtualFileSystem = class VirtualFileSystem {
2466
2591
  * @returns The contents of the file as a string, or undefined if the file does not exist.
2467
2592
  */
2468
2593
  readSync(path) {
2469
- const filePath = this.resolveSync(path);
2594
+ const filePath = this.resolveSync(path, void 0, { isFile: true });
2470
2595
  if (!filePath || !this.existsSync(filePath)) return;
2471
2596
  const { adapter } = this.#getStorage(filePath);
2472
2597
  this.#log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -2489,21 +2614,7 @@ var VirtualFileSystem = class VirtualFileSystem {
2489
2614
  try {
2490
2615
  if (!options.skipFormat) code = await format(this.#context, resolvedPath, data);
2491
2616
  } catch (err) {
2492
- if ([
2493
- "js",
2494
- "ts",
2495
- "cjs",
2496
- "cts",
2497
- "mjs",
2498
- "mts",
2499
- "tsx",
2500
- "jsx",
2501
- "json",
2502
- "json5",
2503
- "jsonc",
2504
- "md",
2505
- "mdx"
2506
- ].includes((0, __stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#log(__storm_software_config_tools_types.LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
2617
+ if (DEFAULT_EXTENSIONS.includes((0, __stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#log(__storm_software_config_tools_types.LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
2507
2618
  code = data;
2508
2619
  }
2509
2620
  this.#log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, __stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, __stryke_convert_to_array.toArray)(code)).size)})`);
@@ -2617,44 +2728,17 @@ var VirtualFileSystem = class VirtualFileSystem {
2617
2728
  * @returns A promise that resolves to the resolved module path.
2618
2729
  */
2619
2730
  async resolve(id, importer, options = {}) {
2620
- let path = id;
2621
- if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
2622
- if (options.skipAlias !== true) path = this.resolveAlias(path);
2623
- if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
2624
- const resolverCacheKey = (0, __stryke_hash.murmurhash)({
2625
- path: this.#normalizeId(path),
2626
- importer,
2627
- options
2628
- });
2629
- let result;
2630
- if (!this.#context.config.skipCache) {
2631
- result = this.resolverCache.get(resolverCacheKey);
2632
- if (result) return result;
2633
- }
2634
- result = this.paths[this.#normalizeId(path)];
2635
- if (!result) {
2636
- const paths = options.paths ?? [];
2637
- if (importer && !paths.includes(importer)) paths.push(importer);
2638
- paths.push(this.#context.workspaceConfig.workspaceRoot);
2639
- paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
2640
- paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
2641
- paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => (0, __stryke_path_append.appendPath)(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2642
- for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
2643
- const { relativeKey, adapter } = this.#getStorage(combination);
2644
- if (await adapter.exists(relativeKey)) {
2645
- result = combination;
2646
- break;
2647
- }
2731
+ const origResult = await this.#innerResolve(id, importer, options);
2732
+ if (origResult && options.isFile && await this.isDirectory(origResult)) {
2733
+ const indexResult = await this.resolve((0, __stryke_path_join.joinPaths)(origResult, "index"), importer, options);
2734
+ if (indexResult) return indexResult;
2735
+ if (!(0, __stryke_path_file_path_fns.hasFileExtension)(origResult)) for (const ext of DEFAULT_EXTENSIONS) {
2736
+ const extResult = await this.resolve(`${origResult}.${ext}`, importer, options);
2737
+ if (extResult) return extResult;
2648
2738
  }
2649
- if (!result) try {
2650
- result = await (0, __stryke_fs_resolve.resolve)(path, {
2651
- ...options,
2652
- paths
2653
- });
2654
- } catch {}
2739
+ return;
2655
2740
  }
2656
- if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
2657
- return result;
2741
+ return origResult;
2658
2742
  }
2659
2743
  /**
2660
2744
  * A synchronous helper function to resolve modules using the Jiti resolver
@@ -2673,39 +2757,17 @@ var VirtualFileSystem = class VirtualFileSystem {
2673
2757
  * @returns The resolved module path.
2674
2758
  */
2675
2759
  resolveSync(id, importer, options = {}) {
2676
- let path = id;
2677
- if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
2678
- if (options.skipAlias !== true) path = this.resolveAlias(path);
2679
- if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
2680
- let result;
2681
- if (!this.#context.config.skipCache) {
2682
- result = this.resolverCache.get(this.#normalizeId(path));
2683
- if (result) return result;
2684
- }
2685
- result = this.paths[this.#normalizeId(path)];
2686
- if (!result) {
2687
- const paths = options.paths ?? [];
2688
- if (importer && !paths.includes(importer)) paths.push(importer);
2689
- paths.push(this.#context.workspaceConfig.workspaceRoot);
2690
- paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
2691
- paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
2692
- paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => (0, __stryke_path_append.appendPath)(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2693
- for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
2694
- const { relativeKey, adapter } = this.#getStorage(combination);
2695
- if (adapter.existsSync(relativeKey)) {
2696
- result = combination;
2697
- break;
2698
- }
2760
+ const origResult = this.#innerResolveSync(id, importer, options);
2761
+ if (origResult && options.isFile && this.isDirectorySync(origResult)) {
2762
+ const indexResult = this.resolveSync((0, __stryke_path_join.joinPaths)(origResult, "index"), importer, options);
2763
+ if (indexResult) return indexResult;
2764
+ if (!(0, __stryke_path_file_path_fns.hasFileExtension)(origResult)) for (const ext of DEFAULT_EXTENSIONS) {
2765
+ const extResult = this.resolveSync(`${origResult}.${ext}`, importer, options);
2766
+ if (extResult) return extResult;
2699
2767
  }
2700
- if (!result) try {
2701
- result = (0, __stryke_fs_resolve.resolveSync)(path, {
2702
- ...options,
2703
- paths
2704
- });
2705
- } catch {}
2768
+ return;
2706
2769
  }
2707
- if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
2708
- return result;
2770
+ return origResult;
2709
2771
  }
2710
2772
  /**
2711
2773
  * Disposes of the virtual file system (VFS) by saving its state to disk.
@@ -78,7 +78,7 @@ import { resolve as resolve$1 } from "node:path";
78
78
  import "unplugin";
79
79
 
80
80
  //#region ../powerlines/package.json
81
- var version = "0.40.8";
81
+ var version = "0.40.10";
82
82
 
83
83
  //#endregion
84
84
  //#region ../powerlines/src/typescript/ts-morph.ts
@@ -1820,6 +1820,24 @@ var VirtualStorageAdapter = class extends BaseStorageAdapter {
1820
1820
  }
1821
1821
  };
1822
1822
 
1823
+ //#endregion
1824
+ //#region ../powerlines/src/_internal/helpers/constants.ts
1825
+ const DEFAULT_EXTENSIONS = [
1826
+ "js",
1827
+ "ts",
1828
+ "cjs",
1829
+ "cts",
1830
+ "mjs",
1831
+ "mts",
1832
+ "tsx",
1833
+ "jsx",
1834
+ "json",
1835
+ "json5",
1836
+ "jsonc",
1837
+ "md",
1838
+ "mdx"
1839
+ ];
1840
+
1823
1841
  //#endregion
1824
1842
  //#region ../powerlines/src/_internal/vfs.ts
1825
1843
  function toFilePath(path) {
@@ -1976,6 +1994,113 @@ var VirtualFileSystem = class VirtualFileSystem {
1976
1994
  }));
1977
1995
  }
1978
1996
  /**
1997
+ * A helper function to resolve modules in the virtual file system (VFS).
1998
+ *
1999
+ * @remarks
2000
+ * This function can be used to resolve modules relative to the project root directory.
2001
+ *
2002
+ * @example
2003
+ * ```ts
2004
+ * const resolved = await context.resolvePath("some-module", "/path/to/importer");
2005
+ * ```
2006
+ *
2007
+ * @param id - The module to resolve.
2008
+ * @param importer - An optional path to the importer module.
2009
+ * @param options - Additional resolution options.
2010
+ * @returns A promise that resolves to the resolved module path.
2011
+ */
2012
+ #innerResolve = async (id, importer, options = {}) => {
2013
+ let path = id;
2014
+ if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
2015
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
2016
+ if (isAbsolutePath(path)) return path;
2017
+ const resolverCacheKey = murmurhash({
2018
+ path: this.#normalizeId(path),
2019
+ importer,
2020
+ options
2021
+ });
2022
+ let result;
2023
+ if (!this.#context.config.skipCache) {
2024
+ result = this.resolverCache.get(resolverCacheKey);
2025
+ if (result) return result;
2026
+ }
2027
+ result = this.paths[this.#normalizeId(path)];
2028
+ if (!result) {
2029
+ const paths = options.paths ?? [];
2030
+ if (importer && !paths.includes(importer)) paths.push(importer);
2031
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
2032
+ paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
2033
+ paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
2034
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2035
+ for (const combination of getResolutionCombinations(path, { paths })) {
2036
+ const { relativeKey, adapter } = this.#getStorage(combination);
2037
+ if (await adapter.exists(relativeKey)) {
2038
+ result = combination;
2039
+ break;
2040
+ }
2041
+ }
2042
+ if (!result) try {
2043
+ result = await resolve(path, {
2044
+ ...options,
2045
+ paths
2046
+ });
2047
+ } catch {}
2048
+ }
2049
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
2050
+ return result;
2051
+ };
2052
+ /**
2053
+ * A synchronous helper function to resolve modules using the Jiti resolver
2054
+ *
2055
+ * @remarks
2056
+ * This function can be used to resolve modules relative to the project root directory.
2057
+ *
2058
+ * @example
2059
+ * ```ts
2060
+ * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
2061
+ * ```
2062
+ *
2063
+ * @param id - The module to resolve.
2064
+ * @param importer - An optional path to the importer module.
2065
+ * @param options - Additional resolution options.
2066
+ * @returns The resolved module path.
2067
+ */
2068
+ #innerResolveSync = (id, importer, options = {}) => {
2069
+ let path = id;
2070
+ if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
2071
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
2072
+ if (isAbsolutePath(path)) return path;
2073
+ let result;
2074
+ if (!this.#context.config.skipCache) {
2075
+ result = this.resolverCache.get(this.#normalizeId(path));
2076
+ if (result) return result;
2077
+ }
2078
+ result = this.paths[this.#normalizeId(path)];
2079
+ if (!result) {
2080
+ const paths = options.paths ?? [];
2081
+ if (importer && !paths.includes(importer)) paths.push(importer);
2082
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
2083
+ paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
2084
+ paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
2085
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2086
+ for (const combination of getResolutionCombinations(path, { paths })) {
2087
+ const { relativeKey, adapter } = this.#getStorage(combination);
2088
+ if (adapter.existsSync(relativeKey)) {
2089
+ result = combination;
2090
+ break;
2091
+ }
2092
+ }
2093
+ if (!result) try {
2094
+ result = resolveSync(path, {
2095
+ ...options,
2096
+ paths
2097
+ });
2098
+ } catch {}
2099
+ }
2100
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
2101
+ return result;
2102
+ };
2103
+ /**
1979
2104
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
1980
2105
  *
1981
2106
  * @param context - The context of the virtual file system, typically containing options and logging functions.
@@ -2447,7 +2572,7 @@ var VirtualFileSystem = class VirtualFileSystem {
2447
2572
  * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
2448
2573
  */
2449
2574
  async read(path) {
2450
- const filePath = await this.resolve(path);
2575
+ const filePath = await this.resolve(path, void 0, { isFile: true });
2451
2576
  if (!filePath || !this.existsSync(filePath)) return;
2452
2577
  const { adapter } = this.#getStorage(filePath);
2453
2578
  this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -2460,7 +2585,7 @@ var VirtualFileSystem = class VirtualFileSystem {
2460
2585
  * @returns The contents of the file as a string, or undefined if the file does not exist.
2461
2586
  */
2462
2587
  readSync(path) {
2463
- const filePath = this.resolveSync(path);
2588
+ const filePath = this.resolveSync(path, void 0, { isFile: true });
2464
2589
  if (!filePath || !this.existsSync(filePath)) return;
2465
2590
  const { adapter } = this.#getStorage(filePath);
2466
2591
  this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -2483,21 +2608,7 @@ var VirtualFileSystem = class VirtualFileSystem {
2483
2608
  try {
2484
2609
  if (!options.skipFormat) code = await format$1(this.#context, resolvedPath, data);
2485
2610
  } catch (err) {
2486
- if ([
2487
- "js",
2488
- "ts",
2489
- "cjs",
2490
- "cts",
2491
- "mjs",
2492
- "mts",
2493
- "tsx",
2494
- "jsx",
2495
- "json",
2496
- "json5",
2497
- "jsonc",
2498
- "md",
2499
- "mdx"
2500
- ].includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#log(LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
2611
+ if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#log(LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
2501
2612
  code = data;
2502
2613
  }
2503
2614
  this.#log(LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob$1(toArray(code)).size)})`);
@@ -2611,44 +2722,17 @@ var VirtualFileSystem = class VirtualFileSystem {
2611
2722
  * @returns A promise that resolves to the resolved module path.
2612
2723
  */
2613
2724
  async resolve(id, importer, options = {}) {
2614
- let path = id;
2615
- if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
2616
- if (options.skipAlias !== true) path = this.resolveAlias(path);
2617
- if (isAbsolutePath(path)) return path;
2618
- const resolverCacheKey = murmurhash({
2619
- path: this.#normalizeId(path),
2620
- importer,
2621
- options
2622
- });
2623
- let result;
2624
- if (!this.#context.config.skipCache) {
2625
- result = this.resolverCache.get(resolverCacheKey);
2626
- if (result) return result;
2627
- }
2628
- result = this.paths[this.#normalizeId(path)];
2629
- if (!result) {
2630
- const paths = options.paths ?? [];
2631
- if (importer && !paths.includes(importer)) paths.push(importer);
2632
- paths.push(this.#context.workspaceConfig.workspaceRoot);
2633
- paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
2634
- paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
2635
- paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2636
- for (const combination of getResolutionCombinations(path, { paths })) {
2637
- const { relativeKey, adapter } = this.#getStorage(combination);
2638
- if (await adapter.exists(relativeKey)) {
2639
- result = combination;
2640
- break;
2641
- }
2725
+ const origResult = await this.#innerResolve(id, importer, options);
2726
+ if (origResult && options.isFile && await this.isDirectory(origResult)) {
2727
+ const indexResult = await this.resolve(joinPaths$1(origResult, "index"), importer, options);
2728
+ if (indexResult) return indexResult;
2729
+ if (!hasFileExtension(origResult)) for (const ext of DEFAULT_EXTENSIONS) {
2730
+ const extResult = await this.resolve(`${origResult}.${ext}`, importer, options);
2731
+ if (extResult) return extResult;
2642
2732
  }
2643
- if (!result) try {
2644
- result = await resolve(path, {
2645
- ...options,
2646
- paths
2647
- });
2648
- } catch {}
2733
+ return;
2649
2734
  }
2650
- if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
2651
- return result;
2735
+ return origResult;
2652
2736
  }
2653
2737
  /**
2654
2738
  * A synchronous helper function to resolve modules using the Jiti resolver
@@ -2667,39 +2751,17 @@ var VirtualFileSystem = class VirtualFileSystem {
2667
2751
  * @returns The resolved module path.
2668
2752
  */
2669
2753
  resolveSync(id, importer, options = {}) {
2670
- let path = id;
2671
- if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
2672
- if (options.skipAlias !== true) path = this.resolveAlias(path);
2673
- if (isAbsolutePath(path)) return path;
2674
- let result;
2675
- if (!this.#context.config.skipCache) {
2676
- result = this.resolverCache.get(this.#normalizeId(path));
2677
- if (result) return result;
2678
- }
2679
- result = this.paths[this.#normalizeId(path)];
2680
- if (!result) {
2681
- const paths = options.paths ?? [];
2682
- if (importer && !paths.includes(importer)) paths.push(importer);
2683
- paths.push(this.#context.workspaceConfig.workspaceRoot);
2684
- paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
2685
- paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
2686
- paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2687
- for (const combination of getResolutionCombinations(path, { paths })) {
2688
- const { relativeKey, adapter } = this.#getStorage(combination);
2689
- if (adapter.existsSync(relativeKey)) {
2690
- result = combination;
2691
- break;
2692
- }
2754
+ const origResult = this.#innerResolveSync(id, importer, options);
2755
+ if (origResult && options.isFile && this.isDirectorySync(origResult)) {
2756
+ const indexResult = this.resolveSync(joinPaths$1(origResult, "index"), importer, options);
2757
+ if (indexResult) return indexResult;
2758
+ if (!hasFileExtension(origResult)) for (const ext of DEFAULT_EXTENSIONS) {
2759
+ const extResult = this.resolveSync(`${origResult}.${ext}`, importer, options);
2760
+ if (extResult) return extResult;
2693
2761
  }
2694
- if (!result) try {
2695
- result = resolveSync(path, {
2696
- ...options,
2697
- paths
2698
- });
2699
- } catch {}
2762
+ return;
2700
2763
  }
2701
- if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
2702
- return result;
2764
+ return origResult;
2703
2765
  }
2704
2766
  /**
2705
2767
  * Disposes of the virtual file system (VFS) by saving its state to disk.
@@ -4738,4 +4800,4 @@ ${error.stack}` : "Unknown error"}`);
4738
4800
 
4739
4801
  //#endregion
4740
4802
  export { withExecutor as t };
4741
- //# sourceMappingURL=base-executor-Cng3H0co.mjs.map
4803
+ //# sourceMappingURL=base-executor-DuE-P1yw.mjs.map