@opentf/afw-build 0.2.0 → 0.3.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +10 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentf/afw-build",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The toolchain-neutral core of AFW's build: compiler client, compile targets and file-based routing.",
5
5
  "type": "module",
6
6
  "scripts": {
package/server.js CHANGED
@@ -153,10 +153,16 @@ export async function serverModule(host, root, { exclude = [], i18n = null, page
153
153
  ` const method = request.method.toUpperCase();\n` +
154
154
  ` if (method !== "GET" && method !== "HEAD") return null;\n` +
155
155
  ` const url = new URL(request.url);\n` +
156
- ` const doc = await renderDocument(render, {\n` +
157
- ` shell, url: url.pathname, search: url.search, loaders, baseUrl, i18n: options.i18n ?? null,\n` +
158
- ` loaderContext: { request, query: Object.fromEntries(url.searchParams), locals },\n` +
159
- ` });\n` +
156
+ ` let doc;\n` +
157
+ ` try {\n` +
158
+ ` doc = await renderDocument(render, {\n` +
159
+ ` shell, url: url.pathname, search: url.search, loaders, baseUrl, i18n: options.i18n ?? null,\n` +
160
+ ` loaderContext: { request, query: Object.fromEntries(url.searchParams), locals },\n` +
161
+ ` });\n` +
162
+ ` } catch (e) {\n` +
163
+ ` if (e instanceof Response) return e; // a loader redirected or refused (throw new Response)\n` +
164
+ ` throw e;\n` +
165
+ ` }\n` +
160
166
  ` if (!doc) return null;\n` +
161
167
  ` return new Response(method === "HEAD" ? null : doc.html, {\n` +
162
168
  ` status: doc.status, headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" },\n` +