@opentf/afw-build 0.6.0 → 0.8.0
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/document.js +9 -1
- package/package.json +1 -1
- package/server.js +4 -1
package/document.js
CHANGED
|
@@ -245,6 +245,14 @@ export async function renderDocument(render, {
|
|
|
245
245
|
return { status, html: document, dataJson, loaded: !!match, metadata, route: result.route ?? null };
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
/**
|
|
249
|
+
* The inline route data of a 404 page, so the client adopts it as the 404 page even
|
|
250
|
+
* where the URL matches a route (a loader's `notFound()`, or a static host serving
|
|
251
|
+
* 404.html for a path it has no file for). Mirrors `NOT_FOUND_PAYLOAD` in the
|
|
252
|
+
* `@opentf/afw` runtime (runtime/route-data.js).
|
|
253
|
+
*/
|
|
254
|
+
export const NOT_FOUND_DATA = '{"__afwNotFound":true}';
|
|
255
|
+
|
|
248
256
|
/** The 404 page as a document (`noindex`), or `null` when the app has none. */
|
|
249
257
|
export async function renderNotFound(render, { shell, baseUrl = "", preload = "" } = {}) {
|
|
250
258
|
const result = await render.renderRoute("/__afw_404__");
|
|
@@ -253,7 +261,7 @@ export async function renderNotFound(render, { shell, baseUrl = "", preload = ""
|
|
|
253
261
|
if (preload) head += `\n${preload}`;
|
|
254
262
|
return {
|
|
255
263
|
status: 404,
|
|
256
|
-
html: injectHydrationData(injectMarkup(injectHead(shell, head), result.html), result.hydration),
|
|
264
|
+
html: injectRouteData(injectHydrationData(injectMarkup(injectHead(shell, head), result.html), result.hydration), NOT_FOUND_DATA),
|
|
257
265
|
dataJson: "",
|
|
258
266
|
loaded: false,
|
|
259
267
|
metadata: result.metadata ?? {},
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -235,7 +235,10 @@ export async function serverModule(host, root, { exclude = [], i18n = null, page
|
|
|
235
235
|
` });\n` +
|
|
236
236
|
` };\n` +
|
|
237
237
|
`}\n`
|
|
238
|
-
:
|
|
238
|
+
// No page renders on the server: still export the name, as `undefined`, so a server
|
|
239
|
+
// entry that checks `app.createPageRenderer` (the app starter's) bundles without an
|
|
240
|
+
// "import will always be undefined" warning.
|
|
241
|
+
: `export const createPageRenderer = undefined;\n`;
|
|
239
242
|
const code =
|
|
240
243
|
`import { createApiHandler, createFetchHandler, createLoaderRegistry, createMiddleware, createServerFunctions } from "@opentf/afw/server";\n` +
|
|
241
244
|
[r.imports, m.imports, l.imports, fns.imports].filter(Boolean).join("\n") + "\n" +
|