@absolutejs/absolute 0.19.0-beta.832 → 0.19.0-beta.834

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.
@@ -3433,21 +3433,34 @@ ${registrations}
3433
3433
  if (fileName.startsWith(outDir))
3434
3434
  return fileName.substring(outDir.length + 1);
3435
3435
  return fileName;
3436
- }, hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs)$/.test(path), rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
3437
- if (specifier.endsWith(".ts"))
3438
- return specifier.replace(/\.ts$/, ".js");
3439
- if (hasJsLikeExtension(specifier))
3440
- return specifier;
3436
+ }, hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs)$/.test(path), splitSpecifierAndQuery = (specifier) => {
3437
+ const separator = specifier.indexOf("?");
3438
+ if (separator === -1) {
3439
+ return {
3440
+ path: specifier,
3441
+ query: ""
3442
+ };
3443
+ }
3444
+ return {
3445
+ path: specifier.substring(0, separator),
3446
+ query: specifier.substring(separator)
3447
+ };
3448
+ }, rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
3449
+ const { path, query } = splitSpecifierAndQuery(specifier);
3450
+ if (path.endsWith(".ts"))
3451
+ return `${path.replace(/\.ts$/, ".js")}${query}`;
3452
+ if (hasJsLikeExtension(path))
3453
+ return `${path}${query}`;
3441
3454
  const importerDir = dirname3(importerOutputPath);
3442
- const fileCandidate = resolve5(importerDir, `${specifier}.js`);
3455
+ const fileCandidate = resolve5(importerDir, `${path}.js`);
3443
3456
  if (outputFiles?.has(fileCandidate) || existsSync4(fileCandidate)) {
3444
- return `${specifier}.js`;
3457
+ return `${path}.js${query}`;
3445
3458
  }
3446
- const indexCandidate = resolve5(importerDir, specifier, "index.js");
3459
+ const indexCandidate = resolve5(importerDir, path, "index.js");
3447
3460
  if (outputFiles?.has(indexCandidate) || existsSync4(indexCandidate)) {
3448
- return `${specifier}/index.js`;
3461
+ return `${path}/index.js${query}`;
3449
3462
  }
3450
- return `${specifier}.js`;
3463
+ return `${path}.js${query}`;
3451
3464
  }, isRelativeModuleSpecifier = (specifier) => specifier.startsWith("./") || specifier.startsWith("../"), extractLocalImportSpecifiers = (source, fileName) => {
3452
3465
  const sourceFile = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
3453
3466
  const specifiers = [];
@@ -3963,7 +3976,7 @@ ${fields}
3963
3976
  deferSlots: inlinedTemplate.deferSlots,
3964
3977
  source: result
3965
3978
  };
3966
- }, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors) => {
3979
+ }, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors, cacheBuster) => {
3967
3980
  const entryPath = resolve5(inputPath);
3968
3981
  const allOutputs = [];
3969
3982
  const visited = new Set;
@@ -4017,13 +4030,18 @@ ${fields}
4017
4030
  const fileBase = basename3(sourcePath).replace(/\.[cm]?[tj]sx?$/, ".js");
4018
4031
  return join5(outDir, relativeDir, fileBase);
4019
4032
  };
4033
+ const withCacheBuster = (specifier) => {
4034
+ if (!cacheBuster)
4035
+ return specifier;
4036
+ return specifier.includes("?") ? `${specifier}&t=${cacheBuster}` : `${specifier}?t=${cacheBuster}`;
4037
+ };
4020
4038
  const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
4021
4039
  let processedContent = angularTranspiler.transformSync(sourceCode);
4022
4040
  const outputPath = toOutputPath(actualPath);
4023
4041
  const rewriteBareImport = (prefix, specifier, suffix) => {
4024
4042
  const rewritten = importRewrites.get(specifier);
4025
4043
  if (rewritten) {
4026
- return `${prefix}${rewritten}${suffix}`;
4044
+ return `${prefix}${withCacheBuster(rewritten)}${suffix}`;
4027
4045
  }
4028
4046
  if (specifier.startsWith(".") || specifier.startsWith("/")) {
4029
4047
  return `${prefix}${specifier}${suffix}`;
@@ -4091,20 +4109,20 @@ ${fields}
4091
4109
  if (!resolved2)
4092
4110
  return null;
4093
4111
  const relativeImport = relative3(targetDir, toOutputPath(resolved2)).replace(/\\/g, "/").replace(/\.js$/, "");
4094
- importRewrites.set(specifier, relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`);
4112
+ const relativeRewrite = relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
4113
+ importRewrites.set(specifier, relativeRewrite);
4095
4114
  return resolved2;
4096
4115
  }).filter((path) => Boolean(path));
4097
4116
  const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
4098
4117
  const cacheKey = actualPath;
4099
- if (jitContentCache.get(cacheKey) === contentHash && existsSync4(targetPath)) {
4100
- allOutputs.push(targetPath);
4101
- } else {
4118
+ const shouldWriteFile = cacheBuster ? true : jitContentCache.get(cacheKey) !== contentHash || !existsSync4(targetPath);
4119
+ if (shouldWriteFile) {
4102
4120
  const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath, importRewrites);
4103
4121
  await fs.mkdir(targetDir, { recursive: true });
4104
4122
  await fs.writeFile(targetPath, processedContent, "utf-8");
4105
- allOutputs.push(targetPath);
4106
4123
  jitContentCache.set(cacheKey, contentHash);
4107
4124
  }
4125
+ allOutputs.push(targetPath);
4108
4126
  await Promise.all(localImportPaths.map((importPath) => transpileFile(importPath)));
4109
4127
  };
4110
4128
  await transpileFile(inputPath);
@@ -4596,6 +4614,7 @@ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
4596
4614
  import { mkdir as mkdir2, symlink } from "fs/promises";
4597
4615
  import { tmpdir } from "os";
4598
4616
  import { basename as basename4, dirname as dirname4, join as join6, resolve as resolve6 } from "path";
4617
+ import { pathToFileURL } from "url";
4599
4618
 
4600
4619
  // src/core/islandPageContext.ts
4601
4620
  init_constants();
@@ -5463,6 +5482,7 @@ var ensureAngularCompiler = () => {
5463
5482
  };
5464
5483
  var readAngularPageModule = (value) => isRecord5(value) ? value : null;
5465
5484
  var resolveAngularSsrOutDir = () => process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR ?? join6(tmpdir(), "absolutejs", "generated", "angular-ssr");
5485
+ var createAngularRuntimeCacheBuster = () => `${Date.now().toString(BASE_36_RADIX)}.${Math.random().toString(BASE_36_RADIX).substring(2, RANDOM_ID_END_INDEX)}`;
5466
5486
  var ensureAngularSsrNodeModules = async (outDir) => {
5467
5487
  const outRoot = resolve6(dirname4(dirname4(outDir)));
5468
5488
  const nodeModulesLink = join6(outRoot, "node_modules");
@@ -5486,14 +5506,30 @@ var ensureAngularSsrNodeModules = async (outDir) => {
5486
5506
  };
5487
5507
  var resolveRuntimeAngularModulePath = async (pagePath) => {
5488
5508
  if (!pagePath.endsWith(".ts")) {
5489
- return pagePath;
5509
+ return {
5510
+ path: pagePath,
5511
+ cacheBuster: undefined
5512
+ };
5490
5513
  }
5491
5514
  const outDir = resolveAngularSsrOutDir();
5492
5515
  await ensureAngularSsrNodeModules(outDir);
5493
5516
  const { compileAngularFileJIT: compileAngularFileJIT2 } = await Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular));
5494
- const outputs = await compileAngularFileJIT2(pagePath, outDir, process.cwd());
5517
+ const cacheBuster = createAngularRuntimeCacheBuster();
5518
+ const outputs = await compileAngularFileJIT2(pagePath, outDir, process.cwd(), undefined, cacheBuster);
5495
5519
  const expectedFileName = basename4(pagePath).replace(/\.ts$/, ".js");
5496
- return outputs.find((output) => output.endsWith(`/${expectedFileName}`)) ?? outputs.find((output) => output.endsWith(`\\${expectedFileName}`)) ?? outputs[0] ?? pagePath;
5520
+ const runtimePagePath = outputs.find((output) => output.endsWith(`/${expectedFileName}`)) ?? outputs.find((output) => output.endsWith(`\\${expectedFileName}`)) ?? outputs[0] ?? pagePath;
5521
+ return {
5522
+ path: runtimePagePath,
5523
+ cacheBuster
5524
+ };
5525
+ };
5526
+ var buildRuntimeModuleSpecifier = (modulePath, cacheBuster) => {
5527
+ if (!cacheBuster) {
5528
+ return modulePath;
5529
+ }
5530
+ const moduleUrl = new URL(pathToFileURL(modulePath).href);
5531
+ moduleUrl.searchParams.set("t", cacheBuster);
5532
+ return moduleUrl.href;
5497
5533
  };
5498
5534
  var withHtmlContentType = (responseInit = {}) => {
5499
5535
  const headers = new Headers(responseInit.headers);
@@ -5548,7 +5584,7 @@ var handleAngularPageRequest = async (input) => {
5548
5584
  const renderPageResponse = async () => {
5549
5585
  const baseDeps = await getAngularDeps();
5550
5586
  const runtimePagePath = await resolveRuntimeAngularModulePath(resolvedPagePath);
5551
- const importedPageModule = await import(runtimePagePath);
5587
+ const importedPageModule = await import(buildRuntimeModuleSpecifier(runtimePagePath.path, runtimePagePath.cacheBuster));
5552
5588
  const pageModule = readAngularPageModule(importedPageModule);
5553
5589
  if (!pageModule) {
5554
5590
  throw new Error(`Invalid Angular page module: ${resolvedPagePath}`);
@@ -5619,5 +5655,5 @@ export {
5619
5655
  ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER
5620
5656
  };
5621
5657
 
5622
- //# debugId=CADCACE62BD9DB2664756E2164756E21
5658
+ //# debugId=4DB1DFC9A3ADCF1564756E2164756E21
5623
5659
  //# sourceMappingURL=server.js.map