@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.
@@ -29960,7 +29960,9 @@ var renderVueIslandToHtml = (component, props) => {
29960
29960
  };
29961
29961
 
29962
29962
  // src/core/svelteServerModule.ts
29963
- import { dirname as dirname2, extname, relative, resolve as resolve3 } from "path";
29963
+ import { mkdir } from "fs/promises";
29964
+ import { dirname as dirname2, extname, join as join2, relative, resolve as resolve3 } from "path";
29965
+ var serverCacheRoot = join2(process.cwd(), ".absolutejs", "islands", "svelte");
29964
29966
  var compiledModuleCache = new Map;
29965
29967
  var transpiler = new Bun.Transpiler({
29966
29968
  loader: "ts",
@@ -29970,6 +29972,11 @@ var ensureRelativeImportPath = (from, to) => {
29970
29972
  const importPath = relative(dirname2(from), to).replace(/\\/g, "/");
29971
29973
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
29972
29974
  };
29975
+ var getCachedModulePath = (sourcePath) => {
29976
+ const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
29977
+ const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
29978
+ return join2(serverCacheRoot, `${normalizedSourcePath}.server.js`);
29979
+ };
29973
29980
  var resolveSvelteImport = async (spec, from) => {
29974
29981
  if (spec.startsWith("/")) {
29975
29982
  return spec;
@@ -29987,6 +29994,17 @@ var resolveSvelteImport = async (spec, from) => {
29987
29994
  }
29988
29995
  return null;
29989
29996
  };
29997
+ var writeIfChanged = async (path, content) => {
29998
+ const targetFile = Bun.file(path);
29999
+ const exists = await targetFile.exists();
30000
+ if (exists) {
30001
+ const currentContent = await targetFile.text();
30002
+ if (currentContent === content) {
30003
+ return;
30004
+ }
30005
+ }
30006
+ await Bun.write(path, content);
30007
+ };
29990
30008
  var compileSvelteServerModule = async (sourcePath) => {
29991
30009
  const cachedModulePath = compiledModuleCache.get(sourcePath);
29992
30010
  if (cachedModulePath) {
@@ -30013,10 +30031,11 @@ var compileSvelteServerModule = async (sourcePath) => {
30013
30031
  generate: "server"
30014
30032
  }).js.code;
30015
30033
  for (const [spec, compiledChildPath] of childModulePaths) {
30016
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(`${sourcePath}.server.js`, compiledChildPath));
30034
+ compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
30017
30035
  }
30018
- const compiledModulePath = `${sourcePath}.server.js`;
30019
- await Bun.write(compiledModulePath, compiledCode);
30036
+ const compiledModulePath = getCachedModulePath(sourcePath);
30037
+ await mkdir(dirname2(compiledModulePath), { recursive: true });
30038
+ await writeIfChanged(compiledModulePath, compiledCode);
30020
30039
  compiledModuleCache.set(sourcePath, compiledModulePath);
30021
30040
  return compiledModulePath;
30022
30041
  };
@@ -30218,5 +30237,5 @@ export {
30218
30237
  createIsland
30219
30238
  };
30220
30239
 
30221
- //# debugId=08A3EAFE6EDE954F64756E2164756E21
30240
+ //# debugId=7EA4CA944D521D0064756E2164756E21
30222
30241
  //# sourceMappingURL=index.js.map