@absolutejs/absolute 0.19.0-beta.275 → 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.
@@ -30017,7 +30017,9 @@ var renderVueIslandToHtml = (component, props) => {
30017
30017
  };
30018
30018
 
30019
30019
  // src/core/svelteServerModule.ts
30020
- import { dirname as dirname2, extname, relative, resolve as resolve3 } from "path";
30020
+ import { mkdir } from "fs/promises";
30021
+ import { dirname as dirname2, extname, join as join2, relative, resolve as resolve3 } from "path";
30022
+ var serverCacheRoot = join2(process.cwd(), ".absolutejs", "islands", "svelte");
30021
30023
  var compiledModuleCache = new Map;
30022
30024
  var transpiler = new Bun.Transpiler({
30023
30025
  loader: "ts",
@@ -30027,6 +30029,11 @@ var ensureRelativeImportPath = (from, to) => {
30027
30029
  const importPath = relative(dirname2(from), to).replace(/\\/g, "/");
30028
30030
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
30029
30031
  };
30032
+ var getCachedModulePath = (sourcePath) => {
30033
+ const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
30034
+ const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
30035
+ return join2(serverCacheRoot, `${normalizedSourcePath}.server.js`);
30036
+ };
30030
30037
  var resolveSvelteImport = async (spec, from) => {
30031
30038
  if (spec.startsWith("/")) {
30032
30039
  return spec;
@@ -30044,6 +30051,17 @@ var resolveSvelteImport = async (spec, from) => {
30044
30051
  }
30045
30052
  return null;
30046
30053
  };
30054
+ var writeIfChanged = async (path, content) => {
30055
+ const targetFile = Bun.file(path);
30056
+ const exists = await targetFile.exists();
30057
+ if (exists) {
30058
+ const currentContent = await targetFile.text();
30059
+ if (currentContent === content) {
30060
+ return;
30061
+ }
30062
+ }
30063
+ await Bun.write(path, content);
30064
+ };
30047
30065
  var compileSvelteServerModule = async (sourcePath) => {
30048
30066
  const cachedModulePath = compiledModuleCache.get(sourcePath);
30049
30067
  if (cachedModulePath) {
@@ -30070,10 +30088,11 @@ var compileSvelteServerModule = async (sourcePath) => {
30070
30088
  generate: "server"
30071
30089
  }).js.code;
30072
30090
  for (const [spec, compiledChildPath] of childModulePaths) {
30073
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(`${sourcePath}.server.js`, compiledChildPath));
30091
+ compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
30074
30092
  }
30075
- const compiledModulePath = `${sourcePath}.server.js`;
30076
- await Bun.write(compiledModulePath, compiledCode);
30093
+ const compiledModulePath = getCachedModulePath(sourcePath);
30094
+ await mkdir(dirname2(compiledModulePath), { recursive: true });
30095
+ await writeIfChanged(compiledModulePath, compiledCode);
30077
30096
  compiledModuleCache.set(sourcePath, compiledModulePath);
30078
30097
  return compiledModulePath;
30079
30098
  };
@@ -30280,5 +30299,5 @@ export {
30280
30299
  createIsland
30281
30300
  };
30282
30301
 
30283
- //# debugId=C4284C6C0A83203264756E2164756E21
30302
+ //# debugId=C9C94A3CE8027FA864756E2164756E21
30284
30303
  //# sourceMappingURL=index.js.map