Skip to content

Commit 1479263

Browse files
authored
fix: improve windows support (#394)
1 parent 47083f5 commit 1479263

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

.changeset/ten-mangos-rush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
fix: improve windows support

packages/cloudflare/src/cli/build/patches/plugins/eval-manifest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ function evalManifest($PATH, $$$ARGS) {
6060
},
6161
fix: `
6262
function evalManifest($PATH, $$$ARGS) {
63+
const { platform } = require('process');
64+
$PATH = platform === 'win32' ? $PATH.replaceAll('\\\\', '/') : $PATH;
6365
${returnManifests}
6466
throw new Error(\`Unexpected evalManifest(\${$PATH}) call!\`);
6567
}`,

packages/cloudflare/src/cli/build/patches/plugins/find-dir.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ rule:
3636
pattern: function findDir($DIR, $NAME) { $$$_ }
3737
fix: |-
3838
function findDir($DIR, $NAME) {
39+
const { platform } = require('process');
40+
$DIR = platform === 'win32' ? $DIR.replaceAll('\\\\', '/') : $DIR;
3941
if ($DIR.endsWith(".next/server")) {
4042
if ($NAME === "app") {
4143
return ${appExists};

packages/cloudflare/src/cli/build/patches/plugins/load-manifest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ function loadManifest($PATH, $$$ARGS) {
5353
},
5454
fix: `
5555
function loadManifest($PATH, $$$ARGS) {
56+
const { platform } = require('process');
57+
$PATH = platform === 'win32' ? $PATH.replaceAll('\\\\', '/') : $PATH;
5658
${returnManifests}
5759
throw new Error(\`Unexpected loadManifest(\${$PATH}) call!\`);
5860
}`,

packages/cloudflare/src/cli/build/patches/plugins/require-page.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { join } from "node:path";
44
import { type BuildOptions, getPackagePath } from "@opennextjs/aws/build/helper.js";
55
import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js";
66

7+
import { normalizePath } from "../../utils/normalize-path.js";
78
import { patchCode, type RuleConfig } from "../ast/util.js";
89
import type { ContentUpdater } from "./content-updater.js";
910

@@ -41,7 +42,7 @@ async function getRule(buildOpts: BuildOptions) {
4142
appPathsManifests = [];
4243
}
4344

44-
const manifests = pagesManifests.concat(appPathsManifests);
45+
const manifests = pagesManifests.concat(appPathsManifests).map((path) => normalizePath(path));
4546

4647
const htmlFiles = manifests.filter((file) => file.endsWith(".html"));
4748
const jsFiles = manifests.filter((file) => file.endsWith(".js"));
@@ -83,7 +84,8 @@ function requirePage($PAGE, $DIST_DIR, $IS_APP_PATH) {
8384
},
8485
fix: `
8586
function requirePage($PAGE, $DIST_DIR, $IS_APP_PATH) {
86-
const pagePath = getPagePath($$$ARGS);
87+
const { platform } = require('process');
88+
const pagePath = platform === 'win32' ? getPagePath($$$ARGS).replaceAll('\\\\', '/') : getPagePath($$$ARGS);
8789
${fnBody}
8890
}`,
8991
} satisfies RuleConfig;

0 commit comments

Comments
 (0)