@absolutejs/absolute 0.19.0-beta.274 → 0.19.0-beta.276

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.
@@ -29649,7 +29649,9 @@ var renderVueIslandToHtml = (component, props) => {
29649
29649
  };
29650
29650
 
29651
29651
  // src/core/svelteServerModule.ts
29652
- import { dirname as dirname2, extname, relative, resolve as resolve3 } from "path";
29652
+ import { mkdir } from "fs/promises";
29653
+ import { dirname as dirname2, extname, join as join2, relative, resolve as resolve3 } from "path";
29654
+ var serverCacheRoot = join2(process.cwd(), ".absolutejs", "islands", "svelte");
29653
29655
  var compiledModuleCache = new Map;
29654
29656
  var transpiler = new Bun.Transpiler({
29655
29657
  loader: "ts",
@@ -29659,6 +29661,11 @@ var ensureRelativeImportPath = (from, to) => {
29659
29661
  const importPath = relative(dirname2(from), to).replace(/\\/g, "/");
29660
29662
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
29661
29663
  };
29664
+ var getCachedModulePath = (sourcePath) => {
29665
+ const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
29666
+ const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
29667
+ return join2(serverCacheRoot, `${normalizedSourcePath}.server.js`);
29668
+ };
29662
29669
  var resolveSvelteImport = async (spec, from) => {
29663
29670
  if (spec.startsWith("/")) {
29664
29671
  return spec;
@@ -29676,6 +29683,17 @@ var resolveSvelteImport = async (spec, from) => {
29676
29683
  }
29677
29684
  return null;
29678
29685
  };
29686
+ var writeIfChanged = async (path, content) => {
29687
+ const targetFile = Bun.file(path);
29688
+ const exists = await targetFile.exists();
29689
+ if (exists) {
29690
+ const currentContent = await targetFile.text();
29691
+ if (currentContent === content) {
29692
+ return;
29693
+ }
29694
+ }
29695
+ await Bun.write(path, content);
29696
+ };
29679
29697
  var compileSvelteServerModule = async (sourcePath) => {
29680
29698
  const cachedModulePath = compiledModuleCache.get(sourcePath);
29681
29699
  if (cachedModulePath) {
@@ -29702,10 +29720,11 @@ var compileSvelteServerModule = async (sourcePath) => {
29702
29720
  generate: "server"
29703
29721
  }).js.code;
29704
29722
  for (const [spec, compiledChildPath] of childModulePaths) {
29705
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(`${sourcePath}.server.js`, compiledChildPath));
29723
+ compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
29706
29724
  }
29707
- const compiledModulePath = `${sourcePath}.server.js`;
29708
- await Bun.write(compiledModulePath, compiledCode);
29725
+ const compiledModulePath = getCachedModulePath(sourcePath);
29726
+ await mkdir(dirname2(compiledModulePath), { recursive: true });
29727
+ await writeIfChanged(compiledModulePath, compiledCode);
29709
29728
  compiledModuleCache.set(sourcePath, compiledModulePath);
29710
29729
  return compiledModulePath;
29711
29730
  };
@@ -29809,5 +29828,5 @@ export {
29809
29828
  defineIslandComponent
29810
29829
  };
29811
29830
 
29812
- //# debugId=CD2F13CE2603674564756E2164756E21
29831
+ //# debugId=03F00B86090EA61364756E2164756E21
29813
29832
  //# sourceMappingURL=index.js.map