@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.
@@ -39142,7 +39142,9 @@ var renderVueIslandToHtml = (component, props) => {
39142
39142
  };
39143
39143
 
39144
39144
  // src/core/svelteServerModule.ts
39145
- import { dirname as dirname2, extname, relative, resolve as resolve3 } from "path";
39145
+ import { mkdir } from "fs/promises";
39146
+ import { dirname as dirname2, extname, join as join2, relative, resolve as resolve3 } from "path";
39147
+ var serverCacheRoot = join2(process.cwd(), ".absolutejs", "islands", "svelte");
39146
39148
  var compiledModuleCache = new Map;
39147
39149
  var transpiler = new Bun.Transpiler({
39148
39150
  loader: "ts",
@@ -39152,6 +39154,11 @@ var ensureRelativeImportPath = (from, to) => {
39152
39154
  const importPath = relative(dirname2(from), to).replace(/\\/g, "/");
39153
39155
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
39154
39156
  };
39157
+ var getCachedModulePath = (sourcePath) => {
39158
+ const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
39159
+ const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
39160
+ return join2(serverCacheRoot, `${normalizedSourcePath}.server.js`);
39161
+ };
39155
39162
  var resolveSvelteImport = async (spec, from) => {
39156
39163
  if (spec.startsWith("/")) {
39157
39164
  return spec;
@@ -39169,6 +39176,17 @@ var resolveSvelteImport = async (spec, from) => {
39169
39176
  }
39170
39177
  return null;
39171
39178
  };
39179
+ var writeIfChanged = async (path, content) => {
39180
+ const targetFile = Bun.file(path);
39181
+ const exists = await targetFile.exists();
39182
+ if (exists) {
39183
+ const currentContent = await targetFile.text();
39184
+ if (currentContent === content) {
39185
+ return;
39186
+ }
39187
+ }
39188
+ await Bun.write(path, content);
39189
+ };
39172
39190
  var compileSvelteServerModule = async (sourcePath) => {
39173
39191
  const cachedModulePath = compiledModuleCache.get(sourcePath);
39174
39192
  if (cachedModulePath) {
@@ -39195,10 +39213,11 @@ var compileSvelteServerModule = async (sourcePath) => {
39195
39213
  generate: "server"
39196
39214
  }).js.code;
39197
39215
  for (const [spec, compiledChildPath] of childModulePaths) {
39198
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(`${sourcePath}.server.js`, compiledChildPath));
39216
+ compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
39199
39217
  }
39200
- const compiledModulePath = `${sourcePath}.server.js`;
39201
- await Bun.write(compiledModulePath, compiledCode);
39218
+ const compiledModulePath = getCachedModulePath(sourcePath);
39219
+ await mkdir(dirname2(compiledModulePath), { recursive: true });
39220
+ await writeIfChanged(compiledModulePath, compiledCode);
39202
39221
  compiledModuleCache.set(sourcePath, compiledModulePath);
39203
39222
  return compiledModulePath;
39204
39223
  };
@@ -39416,5 +39435,5 @@ export {
39416
39435
  IslandState
39417
39436
  };
39418
39437
 
39419
- //# debugId=CC9557494B06448364756E2164756E21
39438
+ //# debugId=ED511B5062F52F9E64756E2164756E21
39420
39439
  //# sourceMappingURL=index.js.map