@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.
package/dist/vue/index.js CHANGED
@@ -29968,7 +29968,9 @@ var renderVueIslandToHtml = (component, props) => {
29968
29968
  };
29969
29969
 
29970
29970
  // src/core/svelteServerModule.ts
29971
- import { dirname as dirname2, extname, relative, resolve as resolve3 } from "path";
29971
+ import { mkdir } from "fs/promises";
29972
+ import { dirname as dirname2, extname, join as join2, relative, resolve as resolve3 } from "path";
29973
+ var serverCacheRoot = join2(process.cwd(), ".absolutejs", "islands", "svelte");
29972
29974
  var compiledModuleCache = new Map;
29973
29975
  var transpiler = new Bun.Transpiler({
29974
29976
  loader: "ts",
@@ -29978,6 +29980,11 @@ var ensureRelativeImportPath = (from, to) => {
29978
29980
  const importPath = relative(dirname2(from), to).replace(/\\/g, "/");
29979
29981
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
29980
29982
  };
29983
+ var getCachedModulePath = (sourcePath) => {
29984
+ const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
29985
+ const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
29986
+ return join2(serverCacheRoot, `${normalizedSourcePath}.server.js`);
29987
+ };
29981
29988
  var resolveSvelteImport = async (spec, from) => {
29982
29989
  if (spec.startsWith("/")) {
29983
29990
  return spec;
@@ -29995,6 +30002,17 @@ var resolveSvelteImport = async (spec, from) => {
29995
30002
  }
29996
30003
  return null;
29997
30004
  };
30005
+ var writeIfChanged = async (path, content) => {
30006
+ const targetFile = Bun.file(path);
30007
+ const exists = await targetFile.exists();
30008
+ if (exists) {
30009
+ const currentContent = await targetFile.text();
30010
+ if (currentContent === content) {
30011
+ return;
30012
+ }
30013
+ }
30014
+ await Bun.write(path, content);
30015
+ };
29998
30016
  var compileSvelteServerModule = async (sourcePath) => {
29999
30017
  const cachedModulePath = compiledModuleCache.get(sourcePath);
30000
30018
  if (cachedModulePath) {
@@ -30021,10 +30039,11 @@ var compileSvelteServerModule = async (sourcePath) => {
30021
30039
  generate: "server"
30022
30040
  }).js.code;
30023
30041
  for (const [spec, compiledChildPath] of childModulePaths) {
30024
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(`${sourcePath}.server.js`, compiledChildPath));
30042
+ compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
30025
30043
  }
30026
- const compiledModulePath = `${sourcePath}.server.js`;
30027
- await Bun.write(compiledModulePath, compiledCode);
30044
+ const compiledModulePath = getCachedModulePath(sourcePath);
30045
+ await mkdir(dirname2(compiledModulePath), { recursive: true });
30046
+ await writeIfChanged(compiledModulePath, compiledCode);
30028
30047
  compiledModuleCache.set(sourcePath, compiledModulePath);
30029
30048
  return compiledModulePath;
30030
30049
  };
@@ -30265,5 +30284,5 @@ export {
30265
30284
  createIsland
30266
30285
  };
30267
30286
 
30268
- //# debugId=20DC5D5A55666F8064756E2164756E21
30287
+ //# debugId=E5B7F63AE100989964756E2164756E21
30269
30288
  //# sourceMappingURL=index.js.map