-
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
- Loading branch information
1 parent
bcaaec6
commit 193aa27
Showing
2 changed files
with
21 additions
and
4 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
19 changes: 19 additions & 0 deletions
19
...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,19 @@ | ||
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")) | ||
: {}; | ||
|
||
return code.replace(/require\(this.middlewareManifestPath\)/, JSON.stringify(middlewareManifest)); | ||
} |