powerlines 0.40.8 → 0.40.10

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 (117) hide show
  1. package/dist/{api-BzGTFyWR.cjs → api-Ba2OWiVz.cjs} +143 -83
  2. package/dist/{api-xhHbbe1P.mjs → api-D9WIJJt3.mjs} +144 -84
  3. package/dist/api-D9WIJJt3.mjs.map +1 -0
  4. package/dist/astro.cjs +2 -2
  5. package/dist/astro.d.cts +1 -1
  6. package/dist/astro.d.mts +5 -5
  7. package/dist/astro.mjs +2 -2
  8. package/dist/{config-C60sAYU4.d.cts → config-BS54DOEG.d.mts} +2 -2
  9. package/dist/{config-C60sAYU4.d.cts.map → config-BS54DOEG.d.mts.map} +1 -1
  10. package/dist/{config-CzpJjE2i.d.mts → config-BXRlCZ9z.d.cts} +2 -2
  11. package/dist/{config-CzpJjE2i.d.mts.map → config-BXRlCZ9z.d.cts.map} +1 -1
  12. package/dist/{config-B3Xvipn4.d.cts → config-CqsFCFR8.d.cts} +5 -1
  13. package/dist/config-CqsFCFR8.d.cts.map +1 -0
  14. package/dist/{config-BLihpN3D.d.mts → config-zlkThEoC.d.mts} +5 -1
  15. package/dist/config-zlkThEoC.d.mts.map +1 -0
  16. package/dist/config.d.cts +1 -1
  17. package/dist/config.d.mts +2 -2
  18. package/dist/context/index.cjs +1 -1
  19. package/dist/context/index.d.cts +1 -1
  20. package/dist/context/index.d.mts +4 -4
  21. package/dist/context/index.mjs +1 -1
  22. package/dist/{esbuild-TSogN2zo.mjs → esbuild-CCuAvKw8.mjs} +2 -2
  23. package/dist/{esbuild-TSogN2zo.mjs.map → esbuild-CCuAvKw8.mjs.map} +1 -1
  24. package/dist/{esbuild-DyzavNz9.cjs → esbuild-CYu81t25.cjs} +1 -1
  25. package/dist/esbuild.cjs +2 -2
  26. package/dist/esbuild.d.cts +1 -1
  27. package/dist/esbuild.d.mts +4 -4
  28. package/dist/esbuild.mjs +2 -2
  29. package/dist/farm.cjs +1 -1
  30. package/dist/farm.d.cts +1 -1
  31. package/dist/farm.d.mts +4 -4
  32. package/dist/farm.mjs +1 -1
  33. package/dist/{index-DQR_ke3L.d.mts → index-BPdDWzbp.d.cts} +2 -2
  34. package/dist/{index-DQR_ke3L.d.mts.map → index-BPdDWzbp.d.cts.map} +1 -1
  35. package/dist/{index-Dv0-yJZY.d.cts → index-CRLhknww.d.mts} +2 -2
  36. package/dist/{index-Dv0-yJZY.d.cts.map → index-CRLhknww.d.mts.map} +1 -1
  37. package/dist/{index-DT3dtimM.d.mts → index-DjfS4slR.d.mts} +2 -2
  38. package/dist/{index-DT3dtimM.d.mts.map → index-DjfS4slR.d.mts.map} +1 -1
  39. package/dist/{index-Ct46ECR2.d.mts → index-PJqBw8CG.d.mts} +2 -2
  40. package/dist/{index-Ct46ECR2.d.mts.map → index-PJqBw8CG.d.mts.map} +1 -1
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.d.cts +5 -5
  43. package/dist/index.d.mts +5 -5
  44. package/dist/index.mjs +1 -1
  45. package/dist/next.cjs +2 -2
  46. package/dist/next.mjs +2 -2
  47. package/dist/nuxt.cjs +3 -3
  48. package/dist/nuxt.d.cts +1 -1
  49. package/dist/nuxt.d.mts +4 -4
  50. package/dist/nuxt.mjs +3 -3
  51. package/dist/{plugin-CiMsERtX.d.mts → plugin-CUXcGRD_.d.mts} +2 -2
  52. package/dist/{plugin-CiMsERtX.d.mts.map → plugin-CUXcGRD_.d.mts.map} +1 -1
  53. package/dist/{plugin-DtbGNmRb.d.cts → plugin-jeRiyjfy.d.cts} +2 -2
  54. package/dist/{plugin-DtbGNmRb.d.cts.map → plugin-jeRiyjfy.d.cts.map} +1 -1
  55. package/dist/plugin-utils.d.cts +3 -3
  56. package/dist/plugin-utils.d.cts.map +1 -1
  57. package/dist/plugin-utils.d.mts +7 -7
  58. package/dist/plugin-utils.d.mts.map +1 -1
  59. package/dist/{plugin-D6FK1hDg.d.cts → plugin-yR7bwKa_.d.cts} +2 -2
  60. package/dist/{plugin-D6FK1hDg.d.cts.map → plugin-yR7bwKa_.d.cts.map} +1 -1
  61. package/dist/{rolldown-DDLOK_IW.mjs → rolldown-CHbI0iMF.mjs} +2 -2
  62. package/dist/{rolldown-DDLOK_IW.mjs.map → rolldown-CHbI0iMF.mjs.map} +1 -1
  63. package/dist/{rolldown-BJMg9WkW.cjs → rolldown-CWW8TO6C.cjs} +1 -1
  64. package/dist/rolldown.cjs +2 -2
  65. package/dist/rolldown.d.cts +1 -1
  66. package/dist/rolldown.d.mts +4 -4
  67. package/dist/rolldown.mjs +2 -2
  68. package/dist/rollup.cjs +1 -1
  69. package/dist/rollup.d.cts +1 -1
  70. package/dist/rollup.d.mts +4 -4
  71. package/dist/rollup.mjs +1 -1
  72. package/dist/rspack.cjs +1 -1
  73. package/dist/rspack.d.cts +1 -1
  74. package/dist/rspack.d.mts +4 -4
  75. package/dist/rspack.mjs +1 -1
  76. package/dist/storage/index.d.cts +1 -1
  77. package/dist/storage/index.d.mts +4 -4
  78. package/dist/tsdown.cjs +2 -2
  79. package/dist/tsdown.d.cts +1 -1
  80. package/dist/tsdown.d.mts +4 -4
  81. package/dist/tsdown.mjs +2 -2
  82. package/dist/tsup.cjs +2 -2
  83. package/dist/tsup.d.cts +1 -1
  84. package/dist/tsup.d.mts +4 -4
  85. package/dist/tsup.mjs +2 -2
  86. package/dist/typescript/index.d.cts +1 -1
  87. package/dist/typescript/index.d.mts +4 -4
  88. package/dist/unloader.cjs +1 -1
  89. package/dist/unloader.d.cts +1 -1
  90. package/dist/unloader.d.mts +4 -4
  91. package/dist/unloader.mjs +1 -1
  92. package/dist/unplugin.cjs +1 -1
  93. package/dist/unplugin.d.cts +2 -2
  94. package/dist/unplugin.d.mts +4 -4
  95. package/dist/unplugin.mjs +1 -1
  96. package/dist/utils.d.cts +1 -1
  97. package/dist/utils.d.mts +2 -2
  98. package/dist/{vite-BfMeKUiY.cjs → vite-BSeJ1LCi.cjs} +1 -1
  99. package/dist/{vite-uBqMz6fM.mjs → vite-aRGnKynz.mjs} +2 -2
  100. package/dist/{vite-uBqMz6fM.mjs.map → vite-aRGnKynz.mjs.map} +1 -1
  101. package/dist/vite.cjs +2 -2
  102. package/dist/vite.d.cts +2 -2
  103. package/dist/vite.d.mts +5 -5
  104. package/dist/vite.mjs +2 -2
  105. package/dist/{webpack-DgpInWJE.cjs → webpack-BQiVW7uT.cjs} +1 -1
  106. package/dist/{webpack-CcRwm7fm.mjs → webpack-DlkAraA4.mjs} +2 -2
  107. package/dist/{webpack-CcRwm7fm.mjs.map → webpack-DlkAraA4.mjs.map} +1 -1
  108. package/dist/webpack.cjs +2 -2
  109. package/dist/webpack.d.cts +1 -1
  110. package/dist/webpack.d.mts +4 -4
  111. package/dist/webpack.mjs +2 -2
  112. package/dist/{write-file-BXi3LP7l.d.cts → write-file-D9MsaQ36.d.cts} +2 -2
  113. package/dist/{write-file-BXi3LP7l.d.cts.map → write-file-D9MsaQ36.d.cts.map} +1 -1
  114. package/package.json +28 -28
  115. package/dist/api-xhHbbe1P.mjs.map +0 -1
  116. package/dist/config-B3Xvipn4.d.cts.map +0 -1
  117. package/dist/config-BLihpN3D.d.mts.map +0 -1
@@ -75,7 +75,7 @@ let unplugin = require("unplugin");
75
75
 
76
76
  //#region package.json
77
77
  var name = "powerlines";
78
- var version = "0.40.8";
78
+ var version = "0.40.10";
79
79
 
80
80
  //#endregion
81
81
  //#region src/_internal/helpers/generate-types.ts
@@ -668,6 +668,24 @@ FileSystem._Ids = __stryke_capnp.CompositeList(FileId);
668
668
  FileSystem._Storage = __stryke_capnp.CompositeList(FileStorage);
669
669
  FileSystem._Metadata = __stryke_capnp.CompositeList(FileMetadata);
670
670
 
671
+ //#endregion
672
+ //#region src/_internal/helpers/constants.ts
673
+ const DEFAULT_EXTENSIONS = [
674
+ "js",
675
+ "ts",
676
+ "cjs",
677
+ "cts",
678
+ "mjs",
679
+ "mts",
680
+ "tsx",
681
+ "jsx",
682
+ "json",
683
+ "json5",
684
+ "jsonc",
685
+ "md",
686
+ "mdx"
687
+ ];
688
+
671
689
  //#endregion
672
690
  //#region src/_internal/vfs.ts
673
691
  function toFilePath(path) {
@@ -824,6 +842,113 @@ var VirtualFileSystem = class VirtualFileSystem {
824
842
  }));
825
843
  }
826
844
  /**
845
+ * A helper function to resolve modules in the virtual file system (VFS).
846
+ *
847
+ * @remarks
848
+ * This function can be used to resolve modules relative to the project root directory.
849
+ *
850
+ * @example
851
+ * ```ts
852
+ * const resolved = await context.resolvePath("some-module", "/path/to/importer");
853
+ * ```
854
+ *
855
+ * @param id - The module to resolve.
856
+ * @param importer - An optional path to the importer module.
857
+ * @param options - Additional resolution options.
858
+ * @returns A promise that resolves to the resolved module path.
859
+ */
860
+ #innerResolve = async (id, importer, options = {}) => {
861
+ let path = id;
862
+ if (path.includes("{") || path.includes("}")) path = require_paths.replacePathTokens(this.#context, path);
863
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
864
+ if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
865
+ const resolverCacheKey = (0, __stryke_hash.murmurhash)({
866
+ path: this.#normalizeId(path),
867
+ importer,
868
+ options
869
+ });
870
+ let result;
871
+ if (!this.#context.config.skipCache) {
872
+ result = this.resolverCache.get(resolverCacheKey);
873
+ if (result) return result;
874
+ }
875
+ result = this.paths[this.#normalizeId(path)];
876
+ if (!result) {
877
+ const paths = options.paths ?? [];
878
+ if (importer && !paths.includes(importer)) paths.push(importer);
879
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
880
+ paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
881
+ paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
882
+ 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)));
883
+ for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
884
+ const { relativeKey, adapter } = this.#getStorage(combination);
885
+ if (await adapter.exists(relativeKey)) {
886
+ result = combination;
887
+ break;
888
+ }
889
+ }
890
+ if (!result) try {
891
+ result = await (0, __stryke_fs_resolve.resolve)(path, {
892
+ ...options,
893
+ paths
894
+ });
895
+ } catch {}
896
+ }
897
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
898
+ return result;
899
+ };
900
+ /**
901
+ * A synchronous helper function to resolve modules using the Jiti resolver
902
+ *
903
+ * @remarks
904
+ * This function can be used to resolve modules relative to the project root directory.
905
+ *
906
+ * @example
907
+ * ```ts
908
+ * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
909
+ * ```
910
+ *
911
+ * @param id - The module to resolve.
912
+ * @param importer - An optional path to the importer module.
913
+ * @param options - Additional resolution options.
914
+ * @returns The resolved module path.
915
+ */
916
+ #innerResolveSync = (id, importer, options = {}) => {
917
+ let path = id;
918
+ if (path.includes("{") || path.includes("}")) path = require_paths.replacePathTokens(this.#context, path);
919
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
920
+ if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
921
+ let result;
922
+ if (!this.#context.config.skipCache) {
923
+ result = this.resolverCache.get(this.#normalizeId(path));
924
+ if (result) return result;
925
+ }
926
+ result = this.paths[this.#normalizeId(path)];
927
+ if (!result) {
928
+ const paths = options.paths ?? [];
929
+ if (importer && !paths.includes(importer)) paths.push(importer);
930
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
931
+ paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
932
+ paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
933
+ 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)));
934
+ for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
935
+ const { relativeKey, adapter } = this.#getStorage(combination);
936
+ if (adapter.existsSync(relativeKey)) {
937
+ result = combination;
938
+ break;
939
+ }
940
+ }
941
+ if (!result) try {
942
+ result = (0, __stryke_fs_resolve.resolveSync)(path, {
943
+ ...options,
944
+ paths
945
+ });
946
+ } catch {}
947
+ }
948
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
949
+ return result;
950
+ };
951
+ /**
827
952
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
828
953
  *
829
954
  * @param context - The context of the virtual file system, typically containing options and logging functions.
@@ -990,6 +1115,8 @@ var VirtualFileSystem = class VirtualFileSystem {
990
1115
  ...this.#context.config.output.storage
991
1116
  };
992
1117
  this.#storage.virtual ??= new require_virtual.VirtualStorageAdapter(context, { base: "/_virtual" });
1118
+ this.#storage[this.#context.config.output.outputPath] ??= new require_virtual.FileSystemStorageAdapter(context, { base: this.#context.config.output.outputPath });
1119
+ this.#storage[this.#context.config.output.buildPath] ??= new require_virtual.FileSystemStorageAdapter(context, { base: this.#context.config.output.buildPath });
993
1120
  if (this.#context.config.output.storage !== "fs") {
994
1121
  this.#storage[this.#context.artifactsPath] ??= new require_virtual.VirtualStorageAdapter(context, { base: this.#context.artifactsPath });
995
1122
  this.#storage[this.#context.builtinsPath] ??= new require_virtual.VirtualStorageAdapter(context, { base: this.#context.builtinsPath });
@@ -1293,7 +1420,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1293
1420
  * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
1294
1421
  */
1295
1422
  async read(path) {
1296
- const filePath = await this.resolve(path);
1423
+ const filePath = await this.resolve(path, void 0, { isFile: true });
1297
1424
  if (!filePath || !this.existsSync(filePath)) return;
1298
1425
  const { adapter } = this.#getStorage(filePath);
1299
1426
  this.#log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -1306,7 +1433,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1306
1433
  * @returns The contents of the file as a string, or undefined if the file does not exist.
1307
1434
  */
1308
1435
  readSync(path) {
1309
- const filePath = this.resolveSync(path);
1436
+ const filePath = this.resolveSync(path, void 0, { isFile: true });
1310
1437
  if (!filePath || !this.existsSync(filePath)) return;
1311
1438
  const { adapter } = this.#getStorage(filePath);
1312
1439
  this.#log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -1329,21 +1456,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1329
1456
  try {
1330
1457
  if (!options.skipFormat) code = await require_paths.format(this.#context, resolvedPath, data);
1331
1458
  } catch (err) {
1332
- if ([
1333
- "js",
1334
- "ts",
1335
- "cjs",
1336
- "cts",
1337
- "mjs",
1338
- "mts",
1339
- "tsx",
1340
- "jsx",
1341
- "json",
1342
- "json5",
1343
- "jsonc",
1344
- "md",
1345
- "mdx"
1346
- ].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}`);
1459
+ 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}`);
1347
1460
  code = data;
1348
1461
  }
1349
1462
  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)})`);
@@ -1457,43 +1570,14 @@ var VirtualFileSystem = class VirtualFileSystem {
1457
1570
  * @returns A promise that resolves to the resolved module path.
1458
1571
  */
1459
1572
  async resolve(id, importer, options = {}) {
1460
- let path = id;
1461
- if (path.includes("{") || path.includes("}")) path = require_paths.replacePathTokens(this.#context, path);
1462
- if (options.skipAlias !== true) path = this.resolveAlias(path);
1463
- if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
1464
- const resolverCacheKey = (0, __stryke_hash.murmurhash)({
1465
- path: this.#normalizeId(path),
1466
- importer,
1467
- options
1468
- });
1469
- let result;
1470
- if (!this.#context.config.skipCache) {
1471
- result = this.resolverCache.get(resolverCacheKey);
1472
- if (result) return result;
1473
- }
1474
- result = this.paths[this.#normalizeId(path)];
1475
- if (!result) {
1476
- const paths = options.paths ?? [];
1477
- if (importer && !paths.includes(importer)) paths.push(importer);
1478
- paths.push(this.#context.workspaceConfig.workspaceRoot);
1479
- paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
1480
- paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
1481
- 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)));
1482
- for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
1483
- const { relativeKey, adapter } = this.#getStorage(combination);
1484
- if (await adapter.exists(relativeKey)) {
1485
- result = combination;
1486
- break;
1487
- }
1573
+ let result = await this.#innerResolve(id, importer, options);
1574
+ if (result && options.isFile && await this.isDirectory(result) && !(0, __stryke_path_file_path_fns.hasFileExtension)(result)) {
1575
+ for (const ext of DEFAULT_EXTENSIONS) {
1576
+ result = await this.resolve(`${result}.${ext}`, importer, options);
1577
+ if (result) return result;
1488
1578
  }
1489
- if (!result) try {
1490
- result = await (0, __stryke_fs_resolve.resolve)(path, {
1491
- ...options,
1492
- paths
1493
- });
1494
- } catch {}
1579
+ return;
1495
1580
  }
1496
- if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
1497
1581
  return result;
1498
1582
  }
1499
1583
  /**
@@ -1513,38 +1597,14 @@ var VirtualFileSystem = class VirtualFileSystem {
1513
1597
  * @returns The resolved module path.
1514
1598
  */
1515
1599
  resolveSync(id, importer, options = {}) {
1516
- let path = id;
1517
- if (path.includes("{") || path.includes("}")) path = require_paths.replacePathTokens(this.#context, path);
1518
- if (options.skipAlias !== true) path = this.resolveAlias(path);
1519
- if ((0, __stryke_path_is_type.isAbsolutePath)(path)) return path;
1520
- let result;
1521
- if (!this.#context.config.skipCache) {
1522
- result = this.resolverCache.get(this.#normalizeId(path));
1523
- if (result) return result;
1524
- }
1525
- result = this.paths[this.#normalizeId(path)];
1526
- if (!result) {
1527
- const paths = options.paths ?? [];
1528
- if (importer && !paths.includes(importer)) paths.push(importer);
1529
- paths.push(this.#context.workspaceConfig.workspaceRoot);
1530
- paths.push((0, __stryke_path_append.appendPath)(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
1531
- paths.push((0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
1532
- 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)));
1533
- for (const combination of (0, __stryke_fs_resolve.getResolutionCombinations)(path, { paths })) {
1534
- const { relativeKey, adapter } = this.#getStorage(combination);
1535
- if (adapter.existsSync(relativeKey)) {
1536
- result = combination;
1537
- break;
1538
- }
1600
+ let result = this.#innerResolveSync(id, importer, options);
1601
+ if (result && options.isFile && this.isDirectorySync(result) && !(0, __stryke_path_file_path_fns.hasFileExtension)(result)) {
1602
+ for (const ext of DEFAULT_EXTENSIONS) {
1603
+ result = this.resolveSync(`${result}.${ext}`, importer, options);
1604
+ if (result) return result;
1539
1605
  }
1540
- if (!result) try {
1541
- result = (0, __stryke_fs_resolve.resolveSync)(path, {
1542
- ...options,
1543
- paths
1544
- });
1545
- } catch {}
1606
+ return;
1546
1607
  }
1547
- if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
1548
1608
  return result;
1549
1609
  }
1550
1610
  /**
@@ -70,7 +70,7 @@ import { setParseImpl } from "unplugin";
70
70
 
71
71
  //#region package.json
72
72
  var name = "powerlines";
73
- var version = "0.40.8";
73
+ var version = "0.40.10";
74
74
 
75
75
  //#endregion
76
76
  //#region src/_internal/helpers/generate-types.ts
@@ -663,6 +663,24 @@ FileSystem._Ids = $.CompositeList(FileId);
663
663
  FileSystem._Storage = $.CompositeList(FileStorage);
664
664
  FileSystem._Metadata = $.CompositeList(FileMetadata);
665
665
 
666
+ //#endregion
667
+ //#region src/_internal/helpers/constants.ts
668
+ const DEFAULT_EXTENSIONS = [
669
+ "js",
670
+ "ts",
671
+ "cjs",
672
+ "cts",
673
+ "mjs",
674
+ "mts",
675
+ "tsx",
676
+ "jsx",
677
+ "json",
678
+ "json5",
679
+ "jsonc",
680
+ "md",
681
+ "mdx"
682
+ ];
683
+
666
684
  //#endregion
667
685
  //#region src/_internal/vfs.ts
668
686
  function toFilePath(path) {
@@ -819,6 +837,113 @@ var VirtualFileSystem = class VirtualFileSystem {
819
837
  }));
820
838
  }
821
839
  /**
840
+ * A helper function to resolve modules in the virtual file system (VFS).
841
+ *
842
+ * @remarks
843
+ * This function can be used to resolve modules relative to the project root directory.
844
+ *
845
+ * @example
846
+ * ```ts
847
+ * const resolved = await context.resolvePath("some-module", "/path/to/importer");
848
+ * ```
849
+ *
850
+ * @param id - The module to resolve.
851
+ * @param importer - An optional path to the importer module.
852
+ * @param options - Additional resolution options.
853
+ * @returns A promise that resolves to the resolved module path.
854
+ */
855
+ #innerResolve = async (id, importer, options = {}) => {
856
+ let path = id;
857
+ if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
858
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
859
+ if (isAbsolutePath(path)) return path;
860
+ const resolverCacheKey = murmurhash({
861
+ path: this.#normalizeId(path),
862
+ importer,
863
+ options
864
+ });
865
+ let result;
866
+ if (!this.#context.config.skipCache) {
867
+ result = this.resolverCache.get(resolverCacheKey);
868
+ if (result) return result;
869
+ }
870
+ result = this.paths[this.#normalizeId(path)];
871
+ if (!result) {
872
+ const paths = options.paths ?? [];
873
+ if (importer && !paths.includes(importer)) paths.push(importer);
874
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
875
+ paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
876
+ paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
877
+ 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)));
878
+ for (const combination of getResolutionCombinations(path, { paths })) {
879
+ const { relativeKey, adapter } = this.#getStorage(combination);
880
+ if (await adapter.exists(relativeKey)) {
881
+ result = combination;
882
+ break;
883
+ }
884
+ }
885
+ if (!result) try {
886
+ result = await resolve(path, {
887
+ ...options,
888
+ paths
889
+ });
890
+ } catch {}
891
+ }
892
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
893
+ return result;
894
+ };
895
+ /**
896
+ * A synchronous helper function to resolve modules using the Jiti resolver
897
+ *
898
+ * @remarks
899
+ * This function can be used to resolve modules relative to the project root directory.
900
+ *
901
+ * @example
902
+ * ```ts
903
+ * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
904
+ * ```
905
+ *
906
+ * @param id - The module to resolve.
907
+ * @param importer - An optional path to the importer module.
908
+ * @param options - Additional resolution options.
909
+ * @returns The resolved module path.
910
+ */
911
+ #innerResolveSync = (id, importer, options = {}) => {
912
+ let path = id;
913
+ if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
914
+ if (options.skipAlias !== true) path = this.resolveAlias(path);
915
+ if (isAbsolutePath(path)) return path;
916
+ let result;
917
+ if (!this.#context.config.skipCache) {
918
+ result = this.resolverCache.get(this.#normalizeId(path));
919
+ if (result) return result;
920
+ }
921
+ result = this.paths[this.#normalizeId(path)];
922
+ if (!result) {
923
+ const paths = options.paths ?? [];
924
+ if (importer && !paths.includes(importer)) paths.push(importer);
925
+ paths.push(this.#context.workspaceConfig.workspaceRoot);
926
+ paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
927
+ paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
928
+ 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)));
929
+ for (const combination of getResolutionCombinations(path, { paths })) {
930
+ const { relativeKey, adapter } = this.#getStorage(combination);
931
+ if (adapter.existsSync(relativeKey)) {
932
+ result = combination;
933
+ break;
934
+ }
935
+ }
936
+ if (!result) try {
937
+ result = resolveSync(path, {
938
+ ...options,
939
+ paths
940
+ });
941
+ } catch {}
942
+ }
943
+ if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
944
+ return result;
945
+ };
946
+ /**
822
947
  * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
823
948
  *
824
949
  * @param context - The context of the virtual file system, typically containing options and logging functions.
@@ -985,6 +1110,8 @@ var VirtualFileSystem = class VirtualFileSystem {
985
1110
  ...this.#context.config.output.storage
986
1111
  };
987
1112
  this.#storage.virtual ??= new VirtualStorageAdapter(context, { base: "/_virtual" });
1113
+ this.#storage[this.#context.config.output.outputPath] ??= new FileSystemStorageAdapter(context, { base: this.#context.config.output.outputPath });
1114
+ this.#storage[this.#context.config.output.buildPath] ??= new FileSystemStorageAdapter(context, { base: this.#context.config.output.buildPath });
988
1115
  if (this.#context.config.output.storage !== "fs") {
989
1116
  this.#storage[this.#context.artifactsPath] ??= new VirtualStorageAdapter(context, { base: this.#context.artifactsPath });
990
1117
  this.#storage[this.#context.builtinsPath] ??= new VirtualStorageAdapter(context, { base: this.#context.builtinsPath });
@@ -1288,7 +1415,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1288
1415
  * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
1289
1416
  */
1290
1417
  async read(path) {
1291
- const filePath = await this.resolve(path);
1418
+ const filePath = await this.resolve(path, void 0, { isFile: true });
1292
1419
  if (!filePath || !this.existsSync(filePath)) return;
1293
1420
  const { adapter } = this.#getStorage(filePath);
1294
1421
  this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -1301,7 +1428,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1301
1428
  * @returns The contents of the file as a string, or undefined if the file does not exist.
1302
1429
  */
1303
1430
  readSync(path) {
1304
- const filePath = this.resolveSync(path);
1431
+ const filePath = this.resolveSync(path, void 0, { isFile: true });
1305
1432
  if (!filePath || !this.existsSync(filePath)) return;
1306
1433
  const { adapter } = this.#getStorage(filePath);
1307
1434
  this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
@@ -1324,21 +1451,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1324
1451
  try {
1325
1452
  if (!options.skipFormat) code = await format(this.#context, resolvedPath, data);
1326
1453
  } catch (err) {
1327
- if ([
1328
- "js",
1329
- "ts",
1330
- "cjs",
1331
- "cts",
1332
- "mjs",
1333
- "mts",
1334
- "tsx",
1335
- "jsx",
1336
- "json",
1337
- "json5",
1338
- "jsonc",
1339
- "md",
1340
- "mdx"
1341
- ].includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#log(LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
1454
+ if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#log(LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
1342
1455
  code = data;
1343
1456
  }
1344
1457
  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)})`);
@@ -1452,43 +1565,14 @@ var VirtualFileSystem = class VirtualFileSystem {
1452
1565
  * @returns A promise that resolves to the resolved module path.
1453
1566
  */
1454
1567
  async resolve(id, importer, options = {}) {
1455
- let path = id;
1456
- if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
1457
- if (options.skipAlias !== true) path = this.resolveAlias(path);
1458
- if (isAbsolutePath(path)) return path;
1459
- const resolverCacheKey = murmurhash({
1460
- path: this.#normalizeId(path),
1461
- importer,
1462
- options
1463
- });
1464
- let result;
1465
- if (!this.#context.config.skipCache) {
1466
- result = this.resolverCache.get(resolverCacheKey);
1467
- if (result) return result;
1468
- }
1469
- result = this.paths[this.#normalizeId(path)];
1470
- if (!result) {
1471
- const paths = options.paths ?? [];
1472
- if (importer && !paths.includes(importer)) paths.push(importer);
1473
- paths.push(this.#context.workspaceConfig.workspaceRoot);
1474
- paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
1475
- paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
1476
- 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)));
1477
- for (const combination of getResolutionCombinations(path, { paths })) {
1478
- const { relativeKey, adapter } = this.#getStorage(combination);
1479
- if (await adapter.exists(relativeKey)) {
1480
- result = combination;
1481
- break;
1482
- }
1568
+ let result = await this.#innerResolve(id, importer, options);
1569
+ if (result && options.isFile && await this.isDirectory(result) && !hasFileExtension(result)) {
1570
+ for (const ext of DEFAULT_EXTENSIONS) {
1571
+ result = await this.resolve(`${result}.${ext}`, importer, options);
1572
+ if (result) return result;
1483
1573
  }
1484
- if (!result) try {
1485
- result = await resolve(path, {
1486
- ...options,
1487
- paths
1488
- });
1489
- } catch {}
1574
+ return;
1490
1575
  }
1491
- if (result && !this.#context.config.skipCache) this.resolverCache.set(resolverCacheKey, result);
1492
1576
  return result;
1493
1577
  }
1494
1578
  /**
@@ -1508,38 +1592,14 @@ var VirtualFileSystem = class VirtualFileSystem {
1508
1592
  * @returns The resolved module path.
1509
1593
  */
1510
1594
  resolveSync(id, importer, options = {}) {
1511
- let path = id;
1512
- if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
1513
- if (options.skipAlias !== true) path = this.resolveAlias(path);
1514
- if (isAbsolutePath(path)) return path;
1515
- let result;
1516
- if (!this.#context.config.skipCache) {
1517
- result = this.resolverCache.get(this.#normalizeId(path));
1518
- if (result) return result;
1519
- }
1520
- result = this.paths[this.#normalizeId(path)];
1521
- if (!result) {
1522
- const paths = options.paths ?? [];
1523
- if (importer && !paths.includes(importer)) paths.push(importer);
1524
- paths.push(this.#context.workspaceConfig.workspaceRoot);
1525
- paths.push(appendPath(this.#context.config.root, this.#context.workspaceConfig.workspaceRoot));
1526
- paths.push(appendPath(joinPaths$1(this.#context.config.root, "src"), this.#context.workspaceConfig.workspaceRoot));
1527
- 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)));
1528
- for (const combination of getResolutionCombinations(path, { paths })) {
1529
- const { relativeKey, adapter } = this.#getStorage(combination);
1530
- if (adapter.existsSync(relativeKey)) {
1531
- result = combination;
1532
- break;
1533
- }
1595
+ let result = this.#innerResolveSync(id, importer, options);
1596
+ if (result && options.isFile && this.isDirectorySync(result) && !hasFileExtension(result)) {
1597
+ for (const ext of DEFAULT_EXTENSIONS) {
1598
+ result = this.resolveSync(`${result}.${ext}`, importer, options);
1599
+ if (result) return result;
1534
1600
  }
1535
- if (!result) try {
1536
- result = resolveSync(path, {
1537
- ...options,
1538
- paths
1539
- });
1540
- } catch {}
1601
+ return;
1541
1602
  }
1542
- if (result && !this.#context.config.skipCache) this.resolverCache.set(this.#normalizeId(path), result);
1543
1603
  return result;
1544
1604
  }
1545
1605
  /**
@@ -3783,4 +3843,4 @@ Note: Please ensure the plugin package's default export is a class that extends
3783
3843
 
3784
3844
  //#endregion
3785
3845
  export { _capnpFileId as _, createUnpluginFactory as a, createUnpluginModuleResolutionFunctions as c, PowerlinesContext as d, FileId as f, FileSystem as g, FileStorage as h, createPluginContext as i, combineContexts as l, FileMetadata_KeyValuePair as m, PowerlinesAPIContext as n, createUnplugin as o, FileMetadata as p, PowerlinesEnvironmentContext as r, createUnpluginResolver as s, PowerlinesAPI as t, isUnpluginBuilderVariant as u, name as v, version as y };
3786
- //# sourceMappingURL=api-xhHbbe1P.mjs.map
3846
+ //# sourceMappingURL=api-D9WIJJt3.mjs.map