Skip to content

Commit df638ff

Browse files
committed
fixup! path separator
1 parent 4a30231 commit df638ff

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

packages/cloudflare/src/cli/build/patches/plugins/dynamic-requires.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ rule:
9393
field: name
9494
regex: ^NodeModuleLoader$
9595
fix: |
96-
async load($ID) {
96+
async load($ID) {
9797
${getRequires("$ID", files, serverDir)}
9898
}`;
9999
}
@@ -119,9 +119,8 @@ function requirePage($PAGE, $DIST_DIR, $IS_APP_PATH) {
119119
}, // Inline fs access and dynamic require that are not supported by workerd.
120120
fix: `
121121
function requirePage($PAGE, $DIST_DIR, $IS_APP_PATH) {
122-
const { platform } = require('process');
123-
const pagePath = platform === 'win32' ? getPagePath($$$ARGS).replaceAll('\\\\', '/') : getPagePath($$$ARGS);
124-
122+
const pagePath = getPagePath($$$ARGS).replaceAll(${JSON.stringify(sep)}, ${JSON.stringify(posix.sep)});
123+
125124
// html
126125
${(
127126
await Promise.all(

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* that are not supported by workerd.
44
*/
55

6-
import { join, relative } from "node:path";
6+
import { join, posix, relative, sep } from "node:path";
77

88
import { type BuildOptions, getPackagePath } from "@opennextjs/aws/build/helper.js";
99
import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js";
@@ -62,8 +62,7 @@ function evalManifest($PATH, $$$ARGS) {
6262
},
6363
fix: `
6464
function evalManifest($PATH, $$$ARGS) {
65-
const { platform } = require('process');
66-
$PATH = platform === 'win32' ? $PATH.replaceAll('\\\\', '/') : $PATH;
65+
$PATH = $PATH.replaceAll(${JSON.stringify(sep)}, ${JSON.stringify(posix.sep)});
6766
${returnManifests}
6867
throw new Error(\`Unexpected evalManifest(\${$PATH}) call!\`);
6968
}`,

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { existsSync } from "node:fs";
6-
import { join } from "node:path";
6+
import { join, posix, sep } from "node:path";
77

88
import { type BuildOptions, getPackagePath } from "@opennextjs/aws/build/helper.js";
99
import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js";
@@ -35,8 +35,7 @@ rule:
3535
pattern: function findDir($DIR, $NAME) { $$$_ }
3636
fix: |-
3737
function findDir($DIR, $NAME) {
38-
const { platform } = require('process');
39-
$DIR = platform === 'win32' ? $DIR.replaceAll('\\\\', '/') : $DIR;
38+
$DIR = $DIR.replaceAll(${JSON.stringify(sep)}, ${JSON.stringify(posix.sep)});
4039
if ($DIR.endsWith(".next/server")) {
4140
if ($NAME === "app") {
4241
return ${appExists};

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { readFile } from "node:fs/promises";
6-
import { join, relative } from "node:path";
6+
import { join, posix, relative, sep } from "node:path";
77

88
import { type BuildOptions, getPackagePath } from "@opennextjs/aws/build/helper.js";
99
import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js";
@@ -53,8 +53,7 @@ function loadManifest($PATH, $$$ARGS) {
5353
},
5454
fix: `
5555
function loadManifest($PATH, $$$ARGS) {
56-
const { platform } = require('process');
57-
$PATH = platform === 'win32' ? $PATH.replaceAll('\\\\', '/') : $PATH;
56+
$PATH = $PATH.replaceAll(${JSON.stringify(sep)}, ${JSON.stringify(posix.sep)});
5857
${returnManifests}
5958
throw new Error(\`Unexpected loadManifest(\${$PATH}) call!\`);
6059
}`,

0 commit comments

Comments
 (0)