Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@ import path from "node:path";
export function inlineEvalManifest(code: string, config: Config): string {
console.log("# inlineEvalManifest");
const manifestJss = globSync(
path.join(config.paths.standaloneAppDotNext, "**", "*_client-reference-manifest.js")
).map((file) => file.replace(`${config.paths.standaloneApp}/`, ""));
path
.join(config.paths.standaloneAppDotNext, "**", "*_client-reference-manifest.js")
.replaceAll(path.sep, path.posix.sep)
).map((file) =>
file
.replaceAll(path.sep, path.posix.sep)
.replace(`${config.paths.standaloneApp.replaceAll(path.sep, path.posix.sep)}/`, "")
);
return code.replace(
/function evalManifest\((.+?), .+?\) {/,
`$&
${manifestJss
.map(
(manifestJs) => `
if ($1.endsWith("${manifestJs}")) {
require("${path.join(config.paths.standaloneApp, manifestJs)}");
require(${JSON.stringify(path.join(config.paths.standaloneApp, manifestJs))});
return {
__RSC_MANIFEST: {
"${manifestJs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function inlineNextRequire(code: string, config: Config) {
.map(
(module) => `
if (pagePath.endsWith("${module}")) {
return require("${path.join(config.paths.standaloneApp, module)}");
return require(${JSON.stringify(path.join(config.paths.standaloneApp, module))});
}
`
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ export function patchReadFile(code: string, config: Config): string {
`
);

// Same as above, the next-server code loads the manifests with `readyFileSync` and we want to avoid that
// Same as above, the next-server code loads the manifests with `readFileSync` and we want to avoid that
// (source: https://github.com/vercel/next.js/blob/15aeb92e/packages/next/src/server/load-manifest.ts#L34-L56)
// Note: we could/should probably just patch readFileSync here or something!
const manifestJsons = globSync(path.join(config.paths.standaloneAppDotNext, "**", "*-manifest.json")).map(
(file) => file.replace(config.paths.standaloneApp + "/", "")
const manifestJsons = globSync(
path.join(config.paths.standaloneAppDotNext, "**", "*-manifest.json").replaceAll(path.sep, path.posix.sep)
).map((file) =>
file
.replaceAll(path.sep, path.posix.sep)
.replace(config.paths.standaloneApp.replaceAll(path.sep, path.posix.sep) + "/", "")
);
code = code.replace(
/function loadManifest\((.+?), .+?\) {/,
Expand Down