@absolutejs/absolute 0.19.0-beta.1080 → 0.19.0-beta.1082

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/index.js CHANGED
@@ -5940,6 +5940,9 @@ var init_constants = __esm(() => {
5940
5940
  TWO_THIRDS = 2 / 3;
5941
5941
  });
5942
5942
 
5943
+ // src/utils/runtimeMode.ts
5944
+ var ENV_VAR = "NODE_ENV", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
5945
+
5943
5946
  // src/core/islandManifest.ts
5944
5947
  var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
5945
5948
  const entries = {};
@@ -6668,9 +6671,6 @@ var init_streamingSlots = __esm(() => {
6668
6671
  };
6669
6672
  });
6670
6673
 
6671
- // src/utils/runtimeMode.ts
6672
- var ENV_VAR = "NODE_ENV", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
6673
-
6674
6674
  // src/angular/angularPatch.ts
6675
6675
  var exports_angularPatch = {};
6676
6676
  __export(exports_angularPatch, {
@@ -39052,7 +39052,11 @@ init_constants();
39052
39052
  var asset = (source, name) => {
39053
39053
  const assetPath = source[name];
39054
39054
  if (assetPath === undefined) {
39055
- throw new Error(`Asset "${name}" not found in manifest.`);
39055
+ if (isProductionRuntime()) {
39056
+ throw new Error(`Asset "${name}" not found in manifest.`);
39057
+ }
39058
+ console.warn(`[asset] key "${name}" not found in manifest (dev mode \u2014 skipping)`);
39059
+ return "";
39056
39060
  }
39057
39061
  return assetPath;
39058
39062
  };
@@ -40105,6 +40109,25 @@ var prepare = async (configOrPath) => {
40105
40109
  return file5;
40106
40110
  });
40107
40111
  recordStep("create static plugin", stepStartedAt);
40112
+ const isFingerprintedAsset = (pathname) => {
40113
+ if (pathname.startsWith("/.absolutejs/"))
40114
+ return true;
40115
+ const base = pathname.slice(pathname.lastIndexOf("/") + 1);
40116
+ const hash = base.match(/[.-]([0-9a-z]{6,12})\.[0-9a-z]+$/i)?.[1];
40117
+ return hash ? /[0-9]/.test(hash) && /[a-z]/i.test(hash) : false;
40118
+ };
40119
+ const assetCachePlugin = new Elysia8({
40120
+ name: "absolutejs-asset-cache"
40121
+ }).onAfterHandle({ as: "global" }, ({ request, response }) => {
40122
+ if (!(response instanceof Response))
40123
+ return;
40124
+ if (request.method !== "GET" && request.method !== "HEAD")
40125
+ return;
40126
+ const { pathname } = new URL(request.url);
40127
+ if (pathname.endsWith("/") || !/\.[0-9a-z]+$/i.test(pathname))
40128
+ return;
40129
+ response.headers.set("cache-control", isFingerprintedAsset(pathname) ? "public, max-age=31536000, immutable" : "public, max-age=0, must-revalidate");
40130
+ });
40108
40131
  stepStartedAt = performance.now();
40109
40132
  const prerenderDir = join49(buildDir, "_prerendered");
40110
40133
  const prerenderMap = loadPrerenderMap(prerenderDir);
@@ -40137,7 +40160,7 @@ var prepare = async (configOrPath) => {
40137
40160
  });
40138
40161
  stepStartedAt = performance.now();
40139
40162
  const { imageOptimizer: imageOptimizer3 } = await Promise.resolve().then(() => (init_imageOptimizer(), exports_imageOptimizer));
40140
- const absolutejs2 = new Elysia8({ name: "absolutejs-runtime" }).use(imageOptimizer3(config2.images, buildDir)).use(prerenderPlugin).use(staticFiles).use(generatedAssetsPlugin).use(createNotFoundPlugin());
40163
+ const absolutejs2 = new Elysia8({ name: "absolutejs-runtime" }).use(assetCachePlugin).use(imageOptimizer3(config2.images, buildDir)).use(prerenderPlugin).use(staticFiles).use(generatedAssetsPlugin).use(createNotFoundPlugin());
40141
40164
  await withOpenApi(absolutejs2, config2, process.cwd(), false);
40142
40165
  await withTelemetry(absolutejs2, config2, process.cwd());
40143
40166
  recordStep("assemble production runtime", stepStartedAt);
@@ -40146,7 +40169,7 @@ var prepare = async (configOrPath) => {
40146
40169
  }
40147
40170
  stepStartedAt = performance.now();
40148
40171
  const { imageOptimizer: imageOptimizer2 } = await Promise.resolve().then(() => (init_imageOptimizer(), exports_imageOptimizer));
40149
- const absolutejs = new Elysia8({ name: "absolutejs-runtime" }).use(imageOptimizer2(config2.images, buildDir)).use(staticFiles).use(generatedAssetsPlugin).use(createNotFoundPlugin());
40172
+ const absolutejs = new Elysia8({ name: "absolutejs-runtime" }).use(assetCachePlugin).use(imageOptimizer2(config2.images, buildDir)).use(staticFiles).use(generatedAssetsPlugin).use(createNotFoundPlugin());
40150
40173
  await withOpenApi(absolutejs, config2, process.cwd(), false);
40151
40174
  await withTelemetry(absolutejs, config2, process.cwd());
40152
40175
  recordStep("assemble production runtime", stepStartedAt);
@@ -47010,5 +47033,5 @@ export {
47010
47033
  ANGULAR_INIT_TIMEOUT_MS
47011
47034
  };
47012
47035
 
47013
- //# debugId=D08EDC1FBDB79DA364756E2164756E21
47036
+ //# debugId=5C2761F3C51DB90064756E2164756E21
47014
47037
  //# sourceMappingURL=index.js.map