@vercel/next 4.9.1 → 4.9.2

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.
Files changed (2) hide show
  1. package/dist/index.js +54 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12323,24 +12323,22 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12323
12323
  const isOmittedOrNotFound = isOmitted || isNotFound;
12324
12324
  let htmlFsRef = null;
12325
12325
  let postponedPrerender;
12326
+ let postponedState = null;
12326
12327
  let didPostpone = false;
12327
12328
  if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && appDir && !isBlocking) {
12329
+ postponedState = getHTMLPostponedState({ appDir, routeFileNoExt });
12328
12330
  const htmlPath = import_path2.default.join(appDir, `${routeFileNoExt}.html`);
12329
- const metaPath = import_path2.default.join(appDir, `${routeFileNoExt}.meta`);
12330
- if (import_fs_extra3.default.existsSync(htmlPath) && import_fs_extra3.default.existsSync(metaPath)) {
12331
- const meta = JSON.parse(await import_fs_extra3.default.readFile(metaPath, "utf8"));
12332
- if (typeof meta === "object" && meta !== null && "postponed" in meta && typeof meta.postponed === "string") {
12331
+ if (import_fs_extra3.default.existsSync(htmlPath)) {
12332
+ const html = import_fs_extra3.default.readFileSync(htmlPath, "utf8");
12333
+ initialHeaders ??= {};
12334
+ if (postponedState) {
12335
+ initialHeaders["content-type"] = `application/x-nextjs-pre-render; state-length=${postponedState.length}; origin="text/html; charset=utf-8"`;
12336
+ postponedPrerender = postponedState + html;
12333
12337
  didPostpone = true;
12334
- postponedPrerender = meta.postponed;
12335
- initialHeaders ??= {};
12336
- initialHeaders["content-type"] = `application/x-nextjs-pre-render; state-length=${meta.postponed.length}`;
12337
- const html = await import_fs_extra3.default.readFileSync(htmlPath, "utf8");
12338
- postponedPrerender += html;
12339
12338
  } else {
12340
- initialHeaders ??= {};
12341
12339
  initialHeaders["content-type"] = "text/html; charset=utf-8";
12342
- const html = await import_fs_extra3.default.readFileSync(htmlPath, "utf8");
12343
12340
  postponedPrerender = html;
12341
+ didPostpone = false;
12344
12342
  }
12345
12343
  }
12346
12344
  if (!dataRoute?.endsWith(".rsc")) {
@@ -12634,6 +12632,37 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12634
12632
  }
12635
12633
  if (outputPathData && renderingMode !== "PARTIALLY_STATIC" /* PARTIALLY_STATIC */) {
12636
12634
  prerenders[normalizePathData(outputPathData)] = prerender;
12635
+ } else if (outputPathData && routesManifest?.rsc?.dynamicRSCPrerender && routesManifest?.ppr?.chain?.headers && postponedState) {
12636
+ const contentType = `application/x-nextjs-pre-render; state-length=${postponedState.length}; origin=${JSON.stringify(
12637
+ rscContentTypeHeader
12638
+ )}`;
12639
+ prerenders[normalizePathData(outputPathData)] = new import_build_utils.Prerender({
12640
+ expiration: initialRevalidate,
12641
+ staleExpiration: initialExpire,
12642
+ lambda,
12643
+ allowQuery,
12644
+ fallback: isFallback ? null : new import_build_utils.FileBlob({
12645
+ data: postponedState,
12646
+ contentType
12647
+ }),
12648
+ group: prerenderGroup,
12649
+ bypassToken: prerenderManifest.bypassToken,
12650
+ experimentalBypassFor,
12651
+ allowHeader,
12652
+ chain: {
12653
+ outputPath: normalizePathData(outputPathData),
12654
+ headers: routesManifest.ppr.chain.headers
12655
+ },
12656
+ ...isNotFound ? { initialStatus: 404 } : {},
12657
+ initialHeaders: {
12658
+ ...initialHeaders,
12659
+ "content-type": contentType,
12660
+ // Dynamic RSC requests cannot be cached, so we explicity set it
12661
+ // here to ensure that the response is not cached by the browser.
12662
+ "cache-control": "private, no-store, no-cache, max-age=0, must-revalidate",
12663
+ vary: rscVaryHeader
12664
+ }
12665
+ });
12637
12666
  }
12638
12667
  }
12639
12668
  const prefetchSegmentSuffix = routesManifest?.rsc?.prefetchSegmentSuffix;
@@ -13411,6 +13440,20 @@ function normalizePrefetches(prefetches) {
13411
13440
  }
13412
13441
  return updatedPrefetches;
13413
13442
  }
13443
+ function getHTMLPostponedState({
13444
+ appDir,
13445
+ routeFileNoExt
13446
+ }) {
13447
+ const metaPath = import_path2.default.join(appDir, `${routeFileNoExt}.meta`);
13448
+ if (!import_fs_extra3.default.existsSync(metaPath)) {
13449
+ return null;
13450
+ }
13451
+ const meta = JSON.parse(import_fs_extra3.default.readFileSync(metaPath, "utf8"));
13452
+ if (typeof meta !== "object" || meta === null || !("postponed" in meta) || typeof meta.postponed !== "string") {
13453
+ return null;
13454
+ }
13455
+ return meta.postponed;
13456
+ }
13414
13457
 
13415
13458
  // src/create-serverless-config.ts
13416
13459
  function getCustomData(importName, target) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.9.1",
3
+ "version": "4.9.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",