@rsc-kit/core 0.30.27 → 0.30.28
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/edgeShells.d.ts +52 -0
- package/dist/edgeShells.js +98 -0
- package/dist/edgeShells.js.map +1 -0
- package/dist/headers.d.ts +17 -4
- package/dist/headers.js +17 -4
- package/dist/headers.js.map +1 -1
- package/dist/host.js +147 -84
- package/dist/host.js.map +1 -1
- package/dist/vite.js +23 -2
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
package/dist/vite.js
CHANGED
|
@@ -23,6 +23,7 @@ import rsc, { getPluginApi } from "@vitejs/plugin-rsc";
|
|
|
23
23
|
import { loadEnv, parseAst } from "vite";
|
|
24
24
|
import { stampDisplayNames } from "./stableNames.js";
|
|
25
25
|
import { REPORT_FILE, buildReport } from "./buildReport.js";
|
|
26
|
+
import { edgeShells, pprMarker } from "./edgeShells.js";
|
|
26
27
|
import { MANIFEST_PATH, manifestWarning, webManifest } from "./webManifest.js";
|
|
27
28
|
import { ASSET_BASE, allAppAssets, assetFile, appAssets, headTags, shareImageUrls, typeOf, } from "./appAssets.js";
|
|
28
29
|
import { reactCacheImports } from "./reactCache.js";
|
|
@@ -1764,6 +1765,7 @@ async function prerenderAfterBundles(bundle, staticDir, assetsDir, knownActions
|
|
|
1764
1765
|
const collected = [];
|
|
1765
1766
|
let refusal = null;
|
|
1766
1767
|
let results;
|
|
1768
|
+
const build = await engine.buildId?.();
|
|
1767
1769
|
try {
|
|
1768
1770
|
results = await prerender({
|
|
1769
1771
|
engine,
|
|
@@ -1774,7 +1776,7 @@ async function prerenderAfterBundles(bundle, staticDir, assetsDir, knownActions
|
|
|
1774
1776
|
// them, and replayed against a different bundle React finds the
|
|
1775
1777
|
// wrong name in every slot. Unstamped - which is what every build
|
|
1776
1778
|
// before this one wrote - the host cannot tell and resumes anyway.
|
|
1777
|
-
version:
|
|
1779
|
+
version: build,
|
|
1778
1780
|
serviceWorker: offline,
|
|
1779
1781
|
stylesheet: inlineStylesheets === false
|
|
1780
1782
|
? undefined
|
|
@@ -1972,6 +1974,8 @@ ${legend(counted)}
|
|
|
1972
1974
|
.filter((r) => existsSync(join(staticDir, pathKeyOf(r.url) + ".html")))
|
|
1973
1975
|
.map((r) => r.url),
|
|
1974
1976
|
results,
|
|
1977
|
+
shells: edgeShells(results, manifest.routes),
|
|
1978
|
+
build,
|
|
1975
1979
|
};
|
|
1976
1980
|
}
|
|
1977
1981
|
/**
|
|
@@ -8073,7 +8077,7 @@ export function rscKit(options = {}) {
|
|
|
8073
8077
|
const staticDir = clientOut
|
|
8074
8078
|
? join(dirname(clientOut), "server", NITRO_STATIC_DIR)
|
|
8075
8079
|
: join(outDir, NITRO_STATIC_DIR);
|
|
8076
|
-
const { frozen, results } = await prerenderAfterBundles(bundle, staticDir, clientOut ?? publicAssetsDir, builder ? knownActionsOf(builder.config, projectRoot) : []);
|
|
8080
|
+
const { frozen, results, shells, build } = await prerenderAfterBundles(bundle, staticDir, clientOut ?? publicAssetsDir, builder ? knownActionsOf(builder.config, projectRoot) : []);
|
|
8077
8081
|
// The same pages once more, as a module. A Worker has no filesystem, and
|
|
8078
8082
|
// until this existed every Cloudflare deploy rendered its "static" pages
|
|
8079
8083
|
// live, silently - the reader found no directory and fell through. The
|
|
@@ -8109,6 +8113,9 @@ export function rscKit(options = {}) {
|
|
|
8109
8113
|
// after the prerender, and an export taken any earlier left them out.
|
|
8110
8114
|
if (output === "export")
|
|
8111
8115
|
await exportAfterPrerender(results, staticDir, clientOut ?? publicAssetsDir);
|
|
8116
|
+
if (shells.left.length) {
|
|
8117
|
+
log(`ppr: not listed for an edge in ppr.json, so served by the origin: ${shells.left.join("; ")}`);
|
|
8118
|
+
}
|
|
8112
8119
|
// What this build produced, where a deploy can read it without parsing
|
|
8113
8120
|
// vite.config.ts - which can turn export on through RSC_OUTPUT, or
|
|
8114
8121
|
// compute it - or knowing where rsc-kit keeps things inside .output.
|
|
@@ -8122,6 +8129,20 @@ export function rscKit(options = {}) {
|
|
|
8122
8129
|
...compileStep(projectRoot),
|
|
8123
8130
|
...(buildCommands().length ? { commands: buildCommands().map((c) => c.name) } : {}),
|
|
8124
8131
|
}, null, 2) + "\n");
|
|
8132
|
+
// The PPR contract's marker: the pages an edge may answer from a
|
|
8133
|
+
// cached shell, and the build both endpoints will say they belong to.
|
|
8134
|
+
// Written by every server build, with an empty list when there is no
|
|
8135
|
+
// PPR page, so a platform can tell "none" from "an rsc-kit too old to
|
|
8136
|
+
// say". Not by an export, which has no origin to resume against.
|
|
8137
|
+
const marker = join(dirname(clientOut), "ppr.json");
|
|
8138
|
+
if (output !== "export" && build) {
|
|
8139
|
+
writeFileSync(marker, JSON.stringify(pprMarker(build, shells.shells), null, 2) + "\n");
|
|
8140
|
+
}
|
|
8141
|
+
else {
|
|
8142
|
+
// One left by an earlier server build would promise an origin that
|
|
8143
|
+
// is not there.
|
|
8144
|
+
rmSync(marker, { force: true });
|
|
8145
|
+
}
|
|
8125
8146
|
}
|
|
8126
8147
|
},
|
|
8127
8148
|
configResolved(config) {
|