@opennextjs/cloudflare 1.18.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -32,6 +32,11 @@ export function patchVercelOgLibrary(buildOpts) {
|
|
|
32
32
|
if (!existsSync(outputEdgePath)) {
|
|
33
33
|
const tracedEdgePath = path.join(path.dirname(traceInfoPath), tracedNodePath.replace("index.node.js", "index.edge.js"));
|
|
34
34
|
copyFileSync(tracedEdgePath, outputEdgePath);
|
|
35
|
+
// On Next 16.2 and above, we also need to copy the yoga.wasm file used by the library.
|
|
36
|
+
const tracedWasmPath = path.join(path.dirname(traceInfoPath), tracedNodePath.replace("index.node.js", "yoga.wasm"));
|
|
37
|
+
if (existsSync(tracedWasmPath)) {
|
|
38
|
+
copyFileSync(tracedWasmPath, path.join(outputDir, "yoga.wasm"));
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
// Change font fetches in the library to use imports.
|
|
37
42
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type BuildOptions } from "@opennextjs/aws/build/helper.js";
|
|
2
2
|
import type { ContentUpdater, Plugin } from "@opennextjs/aws/plugins/content-updater.js";
|
|
3
|
+
export declare function getRequires(idVariable: string, files: string[], serverDir: string): string;
|
|
3
4
|
export declare function inlineDynamicRequires(updater: ContentUpdater, buildOpts: BuildOptions): Plugin;
|
|
@@ -25,9 +25,13 @@ async function getAppPathsManifests(serverDir) {
|
|
|
25
25
|
function getServerDir(buildOpts) {
|
|
26
26
|
return join(buildOpts.outputDir, "server-functions/default", getPackagePath(buildOpts), ".next/server");
|
|
27
27
|
}
|
|
28
|
-
function getRequires(idVariable, files, serverDir) {
|
|
28
|
+
export function getRequires(idVariable, files, serverDir) {
|
|
29
29
|
// Inline fs access and dynamic requires that are not supported by workerd.
|
|
30
|
-
|
|
30
|
+
// Sort by path length descending so longer (more specific) paths match first.
|
|
31
|
+
// Without this, `/test/app/page.js` could match the `.endsWith("app/page.js")`
|
|
32
|
+
// check for `/` before reaching the correct `.endsWith("test/app/page.js")` check.
|
|
33
|
+
const sorted = [...files].sort((a, b) => b.length - a.length);
|
|
34
|
+
return sorted
|
|
31
35
|
.map((file) => `
|
|
32
36
|
if (${idVariable}.replaceAll(${JSON.stringify(sep)}, ${JSON.stringify(posix.sep)}).endsWith(${JSON.stringify(normalizePath(file))})) {
|
|
33
37
|
return require(${JSON.stringify(join(serverDir, file))});
|
|
@@ -93,7 +97,9 @@ async function getRequirePageRule(buildOpts) {
|
|
|
93
97
|
const pagesManifests = await getPagesManifests(serverDir);
|
|
94
98
|
const appPathsManifests = await getAppPathsManifests(serverDir);
|
|
95
99
|
const manifests = pagesManifests.concat(appPathsManifests);
|
|
96
|
-
|
|
100
|
+
// Sort html files by path length descending so longer (more specific) paths
|
|
101
|
+
// match first, preventing suffix collisions in the `.endsWith()` chain (see #1156).
|
|
102
|
+
const htmlFiles = manifests.filter((file) => file.endsWith(".html")).sort((a, b) => b.length - a.length);
|
|
97
103
|
const jsFiles = manifests.filter((file) => file.endsWith(".js"));
|
|
98
104
|
return {
|
|
99
105
|
rule: {
|
|
@@ -78,7 +78,10 @@ async function getEvalManifestRule(buildOpts) {
|
|
|
78
78
|
const manifests = await glob(join(baseDir, "**/*_client-reference-manifest.js"), {
|
|
79
79
|
windowsPathsNoEscape: true,
|
|
80
80
|
});
|
|
81
|
-
|
|
81
|
+
// Sort by path length descending so longer (more specific) paths match first,
|
|
82
|
+
// preventing suffix collisions in the `.endsWith()` chain (see #1156).
|
|
83
|
+
const sortedManifests = [...manifests].sort((a, b) => b.length - a.length);
|
|
84
|
+
const returnManifests = sortedManifests
|
|
82
85
|
.map((manifest) => {
|
|
83
86
|
const endsWith = normalizePath(relative(baseDir, manifest));
|
|
84
87
|
const key = normalizePath("/" + relative(appDir, manifest)).replace("_client-reference-manifest.js", "");
|