-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use incremental cache during rendering (#64)
* feat: use incremental cache during rendering * patch exception bubbling
- Loading branch information
1 parent
bcaaec6
commit ba9af72
Showing
4 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ges/cloudflare/src/cli/build/patches/to-investigate/inline-middleware-manifest-require.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { existsSync, readFileSync } from "node:fs"; | ||
import { Config } from "../../../config"; | ||
import path from "node:path"; | ||
|
||
/** | ||
* Inlines the middleware manifest from the build output to prevent a dynamic require statement | ||
* as they result in runtime failures. | ||
*/ | ||
export function inlineMiddlewareManifestRequire(code: string, config: Config) { | ||
console.log("# inlineMiddlewareManifestRequire"); | ||
|
||
const middlewareManifestPath = path.join(config.paths.standaloneAppServer, "middleware-manifest.json"); | ||
|
||
const middlewareManifest = existsSync(middlewareManifestPath) | ||
? JSON.parse(readFileSync(middlewareManifestPath, "utf-8")) | ||
: {}; | ||
|
||
const patchedCode = code.replace( | ||
"require(this.middlewareManifestPath)", | ||
JSON.stringify(middlewareManifest) | ||
); | ||
|
||
if (patchedCode === code) { | ||
throw new Error("Patch `inlineMiddlewareManifestRequire` not applied"); | ||
} | ||
|
||
return patchedCode; | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/cloudflare/src/cli/build/patches/to-investigate/patch-exception-bubbling.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* When using SSG and `dynamicParams = false`, Next.js throws a NoFallbackError. This error is | ||
* bubbled up by default in Node.js servers, however this causes issues in the workerd with | ||
* the current response handling and streaming implementation we have, and leads to hanging | ||
* promises. | ||
*/ | ||
export function patchExceptionBubbling(code: string) { | ||
console.log("# patchExceptionBubbling"); | ||
|
||
const patchedCode = code.replace('_nextBubbleNoFallback = "1"', "_nextBubbleNoFallback = undefined"); | ||
|
||
if (patchedCode === code) { | ||
throw new Error("Patch `patchExceptionBubbling` not applied"); | ||
} | ||
|
||
return patchedCode; | ||
} |