@decocms/nextjs 7.72.0 → 8.0.0-next.0
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.
package/README.md
CHANGED
|
@@ -359,9 +359,7 @@ implementation file) can opt into these, each read as a literal
|
|
|
359
359
|
|
|
360
360
|
## Verifying your setup
|
|
361
361
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
the build also guards the server/client boundary described above. Use it as
|
|
367
|
-
a working reference if any of the above doesn't compose the way you expect.
|
|
362
|
+
No example app in this monorepo exercises these surfaces any more:
|
|
363
|
+
`examples/nextjs-smoke` now follows the next-major Next.js guide, which uses
|
|
364
|
+
`@decocms/blocks` alone. The surfaces above are covered by this package's unit
|
|
365
|
+
tests.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/nextjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-next.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"lint:unused": "knip"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@decocms/blocks": "
|
|
33
|
-
"@decocms/blocks-admin": "
|
|
32
|
+
"@decocms/blocks": "8.0.0-next.0",
|
|
33
|
+
"@decocms/blocks-admin": "8.0.0-next.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"next": ">=15.0.0",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
/**
|
|
3
|
+
* Conformance: the Next.js half of caching.mdx ("Upstream data": requests go
|
|
4
|
+
* through Next's data cache, no cache of the binding's own) and of
|
|
5
|
+
* telemetry.mdx ("What's sent": the bindings add no measurements of their own;
|
|
6
|
+
* inbound requests come from Next's own OpenTelemetry setup).
|
|
7
|
+
*/
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { createInstrumentedFetch } from "@decocms/blocks/fetch";
|
|
12
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
13
|
+
|
|
14
|
+
const SRC = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
15
|
+
|
|
16
|
+
function sources(): { file: string; text: string }[] {
|
|
17
|
+
const out: { file: string; text: string }[] = [];
|
|
18
|
+
const walk = (dir: string) => {
|
|
19
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
20
|
+
const full = path.join(dir, entry.name);
|
|
21
|
+
if (entry.isDirectory()) {
|
|
22
|
+
if (entry.name !== "__conformance__" && entry.name !== "__tests__") walk(full);
|
|
23
|
+
} else if (/\.(ts|tsx|cjs|js)$/.test(entry.name) && !/\.test\./.test(entry.name)) {
|
|
24
|
+
out.push({ file: path.relative(SRC, full), text: fs.readFileSync(full, "utf8") });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
walk(SRC);
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
vi.unstubAllGlobals();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe("upstream data on Next.js (caching.mdx)", () => {
|
|
37
|
+
it("cache-04: the instrumented fetch goes through the fetch Next patches, with Next's cache options intact", async () => {
|
|
38
|
+
const instrumented = createInstrumentedFetch({ provider: "acme-search" });
|
|
39
|
+
// Next replaces globalThis.fetch after modules load; the instrumented fetch must use it.
|
|
40
|
+
const nextFetch = vi.fn(async () => new Response("{}"));
|
|
41
|
+
vi.stubGlobal("fetch", nextFetch);
|
|
42
|
+
await instrumented("https://search.example/q", {
|
|
43
|
+
operation: "search",
|
|
44
|
+
next: { revalidate: 60, tags: ["search"] },
|
|
45
|
+
} as RequestInit & { operation: string });
|
|
46
|
+
expect(nextFetch).toHaveBeenCalledTimes(1);
|
|
47
|
+
const init = (nextFetch.mock.calls[0] as unknown as [unknown, Record<string, unknown>])[1];
|
|
48
|
+
expect(init.next).toEqual({ revalidate: 60, tags: ["search"] });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("cache-04: @decocms/nextjs has no upstream cache of its own", () => {
|
|
52
|
+
const own = sources().filter(({ text }) =>
|
|
53
|
+
/caches\.default|caches\.open|createFetchCache|fetchWithCache/.test(text),
|
|
54
|
+
);
|
|
55
|
+
expect(own.map((s) => s.file)).toEqual([]);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe("what the binding adds (telemetry.mdx › What's sent)", () => {
|
|
60
|
+
it("tel-09: @decocms/nextjs adds no measurements of its own (no inbound or page-cache metrics)", () => {
|
|
61
|
+
const reporters = sources().filter(({ text }) =>
|
|
62
|
+
/http\.server\.request\.duration|decocms\.blocks\.telemetry/.test(text),
|
|
63
|
+
);
|
|
64
|
+
expect(reporters.map((s) => s.file)).toEqual([]);
|
|
65
|
+
});
|
|
66
|
+
});
|