Skip to content

Commit 8d18ca4

Browse files
authored
fix: Windows support (#81)
1 parent 83abcfe commit 8d18ca4

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

packages/cloudflare/src/cli/build/patches/to-investigate/inline-eval-manifest.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,22 @@ import path from "node:path";
1212
export function inlineEvalManifest(code: string, config: Config): string {
1313
console.log("# inlineEvalManifest");
1414
const manifestJss = globSync(
15-
path.join(config.paths.standaloneAppDotNext, "**", "*_client-reference-manifest.js")
16-
).map((file) => file.replace(`${config.paths.standaloneApp}/`, ""));
15+
path
16+
.join(config.paths.standaloneAppDotNext, "**", "*_client-reference-manifest.js")
17+
.replaceAll(path.sep, path.posix.sep)
18+
).map((file) =>
19+
file
20+
.replaceAll(path.sep, path.posix.sep)
21+
.replace(config.paths.standaloneApp.replaceAll(path.sep, path.posix.sep) + path.posix.sep, "")
22+
);
1723
return code.replace(
1824
/function evalManifest\((.+?), .+?\) {/,
1925
`$&
2026
${manifestJss
2127
.map(
2228
(manifestJs) => `
2329
if ($1.endsWith("${manifestJs}")) {
24-
require("${path.join(config.paths.standaloneApp, manifestJs)}");
30+
require(${JSON.stringify(path.join(config.paths.standaloneApp, manifestJs))});
2531
return {
2632
__RSC_MANIFEST: {
2733
"${manifestJs

packages/cloudflare/src/cli/build/patches/to-investigate/inline-next-require.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function inlineNextRequire(code: string, config: Config) {
4242
.map(
4343
(module) => `
4444
if (pagePath.endsWith("${module}")) {
45-
return require("${path.join(config.paths.standaloneApp, module)}");
45+
return require(${JSON.stringify(path.join(config.paths.standaloneApp, module))});
4646
}
4747
`
4848
)

packages/cloudflare/src/cli/build/patches/to-investigate/patch-read-file.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ export function patchReadFile(code: string, config: Config): string {
1616
`
1717
);
1818

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

0 commit comments

Comments
 (0)