|
1 | 1 | import { readFile } from "node:fs/promises"; |
2 | | -import { join } from "node:path"; |
| 2 | +import { join , posix, sep } from "node:path"; |
3 | 3 |
|
4 | 4 | import { type BuildOptions, getPackagePath } from "@opennextjs/aws/build/helper.js"; |
5 | 5 | import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js"; |
| 6 | +import type { Plugin } from "esbuild"; |
6 | 7 |
|
7 | 8 | import { normalizePath } from "../../utils/normalize-path.js"; |
8 | 9 | import { patchCode, type RuleConfig } from "../ast/util.js"; |
9 | 10 | import type { ContentUpdater } from "./content-updater.js"; |
10 | | -import { posix, sep } from "node:path"; |
11 | | -import type { Plugin } from "esbuild"; |
12 | 11 |
|
13 | 12 | async function getPagesManifests(serverDir: string): Promise<string[]> { |
14 | 13 | try { |
@@ -36,9 +35,8 @@ function getRequires(idVariable: string, files: string[], serverDir: string) { |
36 | 35 | // Inline fs access and dynamic requires that are not supported by workerd. |
37 | 36 | return files |
38 | 37 | .map( |
39 | | - ( |
40 | | - file |
41 | | - ) => `if (${idVariable}.replaceAll(${JSON.stringify(sep)}, ${JSON.stringify(posix.sep)}).endsWith(${JSON.stringify(normalizePath(file))})) { |
| 38 | + (file) => ` |
| 39 | + if (${idVariable}.replaceAll(${JSON.stringify(sep)}, ${JSON.stringify(posix.sep)}).endsWith(${JSON.stringify(normalizePath(file))})) { |
42 | 40 | return require(${JSON.stringify(join(serverDir, file))}); |
43 | 41 | }` |
44 | 42 | ) |
@@ -71,7 +69,7 @@ export function inlineDynamicRequires(updater: ContentUpdater, buildOpts: BuildO |
71 | 69 | async function getNodeModuleLoaderRule(buildOpts: BuildOptions) { |
72 | 70 | const serverDir = getServerDir(buildOpts); |
73 | 71 |
|
74 | | - let manifests = await getPagesManifests(serverDir); |
| 72 | + const manifests = await getPagesManifests(serverDir); |
75 | 73 |
|
76 | 74 | const files = manifests.filter((file) => file.endsWith(".js")); |
77 | 75 |
|
|
0 commit comments