Skip to content

Commit a9d38f5

Browse files
committed
move manifest retrievel to own util for mocking
1 parent 95bb5be commit a9d38f5

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function getPrerenderManifest() {
2+
// TODO: Drop the import - https://github.com/opennextjs/opennextjs-cloudflare/issues/361
3+
// @ts-expect-error
4+
return import("./.next/prerender-manifest.json");
5+
}

packages/cloudflare/src/api/memory-queue.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { beforeAll, describe, expect, it, vi } from "vitest";
33

44
import cache from "./memory-queue";
55

6-
vi.mock("./.next/prerender-manifest.json", () => ({
7-
preview: { previewModeId: "id" },
6+
vi.mock("./internal/manifest.js", () => ({
7+
getPrerenderManifest: () => ({ preview: { previewModeId: "id" } }),
88
}));
99

1010
const defaultOpts = {

packages/cloudflare/src/api/memory-queue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import logger from "@opennextjs/aws/logger.js";
22
import type { Queue, QueueMessage } from "@opennextjs/aws/types/overrides.js";
33

4+
import { getPrerenderManifest } from "./internal/manifest.js";
5+
46
/**
57
* The Memory Queue offers basic ISR revalidation by directly requesting a revalidation of a route.
68
*
@@ -21,9 +23,7 @@ class MemoryQueue implements Queue {
2123
);
2224

2325
try {
24-
// TODO: Drop the import - https://github.com/opennextjs/opennextjs-cloudflare/issues/361
25-
// @ts-expect-error
26-
const manifest = await import("./.next/prerender-manifest.json");
26+
const manifest = await getPrerenderManifest();
2727
const protocol = host.includes("localhost") ? "http" : "https";
2828

2929
await globalThis.internalFetch(`${protocol}://${host}${url}`, {

0 commit comments

Comments
 (0)