@decocms/blocks 8.0.0 → 8.1.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.
Files changed (175) hide show
  1. package/bin/deco.js +13 -0
  2. package/package.json +39 -3
  3. package/src/cms/applySectionConventions.ts +26 -2
  4. package/src/cms/blockSource.ts +37 -0
  5. package/src/cms/client.ts +5 -0
  6. package/src/cms/deferredTrigger.ts +58 -0
  7. package/src/cms/draftSource.ts +171 -57
  8. package/src/cms/index.ts +32 -3
  9. package/src/cms/loader.ts +318 -59
  10. package/src/cms/registry.ts +22 -0
  11. package/src/cms/renderJson.ts +179 -0
  12. package/src/cms/resolve.ts +396 -95
  13. package/src/cms/schema.ts +9 -5
  14. package/src/cms/sectionLoaders.ts +106 -56
  15. package/src/hooks/Image.tsx +70 -6
  16. package/src/hooks/LiveControls.tsx +30 -8
  17. package/src/hooks/Stats.tsx +134 -0
  18. package/src/hooks/index.ts +5 -0
  19. package/src/hooks/useLoadMore.ts +100 -0
  20. package/src/index.ts +37 -0
  21. package/src/middleware/observability.ts +173 -16
  22. package/src/preview/DraftPreviewBadge.tsx +306 -0
  23. package/src/preview/decoMark.ts +11 -0
  24. package/src/preview/index.ts +8 -0
  25. package/src/protocol/assets.ts +124 -0
  26. package/src/protocol/canonical.ts +7 -0
  27. package/src/protocol/ciphertext.ts +6 -0
  28. package/src/protocol/client.ts +170 -0
  29. package/src/protocol/conformance/cases/assets.ts +81 -0
  30. package/src/protocol/conformance/cases/guards.ts +314 -0
  31. package/src/protocol/conformance/cases/reads.ts +168 -0
  32. package/src/protocol/conformance/cases/types.ts +9 -0
  33. package/src/protocol/conformance/cases/wire.ts +138 -0
  34. package/src/protocol/conformance/cases/writes.ts +345 -0
  35. package/src/protocol/conformance/contentHashFixtures.ts +79 -0
  36. package/src/protocol/conformance/context.ts +222 -0
  37. package/src/protocol/conformance/index.ts +140 -0
  38. package/src/protocol/errors.ts +142 -0
  39. package/src/protocol/index.ts +39 -0
  40. package/src/protocol/keys.ts +279 -0
  41. package/src/protocol/params.ts +67 -0
  42. package/src/protocol/secrets.ts +231 -0
  43. package/src/protocol/server/assets.ts +119 -0
  44. package/src/protocol/server/auth.ts +49 -0
  45. package/src/protocol/server/bodyCache.ts +84 -0
  46. package/src/protocol/server/content.ts +175 -0
  47. package/src/protocol/server/core.ts +112 -0
  48. package/src/protocol/server/handler.ts +102 -0
  49. package/src/protocol/server/http.ts +139 -0
  50. package/src/protocol/server/index.ts +11 -0
  51. package/src/protocol/server/methods/apply.ts +341 -0
  52. package/src/protocol/server/methods/read.ts +156 -0
  53. package/src/protocol/server/rpc.ts +136 -0
  54. package/src/protocol/storage/fs/hash.ts +21 -0
  55. package/src/protocol/storage/fs/index.ts +338 -0
  56. package/src/protocol/storage/fs/lock.ts +68 -0
  57. package/src/protocol/storage/fs/transaction.ts +183 -0
  58. package/src/protocol/storage/fs/unsupported.ts +15 -0
  59. package/src/protocol/storage/memory.ts +238 -0
  60. package/src/protocol/storage.ts +182 -0
  61. package/src/protocol/types.ts +172 -0
  62. package/src/sdk/abTesting.ts +60 -3
  63. package/src/sdk/analytics.ts +72 -2
  64. package/src/sdk/cacheHeaders.ts +210 -10
  65. package/src/sdk/cacheStorage.ts +287 -0
  66. package/src/sdk/cachedLoader.ts +143 -90
  67. package/src/sdk/crypto.ts +16 -2
  68. package/src/sdk/deepOmit.ts +52 -0
  69. package/src/sdk/encoding.ts +2 -5
  70. package/src/sdk/experiments.ts +314 -0
  71. package/src/sdk/fetchCache.ts +269 -0
  72. package/src/sdk/fetchTimeout.ts +58 -0
  73. package/src/sdk/flags.ts +38 -8
  74. package/src/sdk/index.ts +7 -0
  75. package/src/sdk/instrumentedFetch.ts +25 -2
  76. package/src/sdk/nonce.ts +46 -0
  77. package/src/sdk/normalizeUrls.ts +2 -2
  78. package/src/sdk/observability.ts +8 -1
  79. package/src/sdk/otel.ts +131 -25
  80. package/src/sdk/otelHttpLog.ts +4 -4
  81. package/src/sdk/otelHttpMeter.ts +39 -13
  82. package/src/sdk/otelHttpTracer.ts +4 -4
  83. package/src/sdk/redirects.ts +113 -5
  84. package/src/sdk/responseCache.ts +82 -0
  85. package/src/sdk/urlUtils.ts +49 -0
  86. package/src/sdk/useSuggestions.ts +1 -1
  87. package/src/v8/analytics.ts +50 -0
  88. package/src/v8/background.ts +107 -0
  89. package/src/v8/builtins/data.ts +23 -0
  90. package/src/v8/builtins/index.ts +26 -0
  91. package/src/v8/builtins/lazy.ts +23 -0
  92. package/src/v8/builtins/legacy.ts +65 -0
  93. package/src/v8/builtins/matchers.ts +31 -0
  94. package/src/v8/builtins/multivariate.ts +25 -0
  95. package/src/v8/builtins/secret.ts +82 -0
  96. package/src/v8/canonical.ts +117 -0
  97. package/src/v8/ciphertext.ts +158 -0
  98. package/src/v8/cli/builtins.ts +20 -0
  99. package/src/v8/cli/check/index.ts +774 -0
  100. package/src/v8/cli/check/messages.ts +168 -0
  101. package/src/v8/cli/content.ts +287 -0
  102. package/src/v8/cli/index.ts +17 -0
  103. package/src/v8/cli/log.ts +18 -0
  104. package/src/v8/cli/main.ts +12 -0
  105. package/src/v8/cli/root.ts +66 -0
  106. package/src/v8/cli/run.ts +236 -0
  107. package/src/v8/cli/schema/builtinSchemas.ts +236 -0
  108. package/src/v8/cli/schema/generate.ts +507 -0
  109. package/src/v8/cli/schema/index.ts +63 -0
  110. package/src/v8/cli/schema/tsProgram.ts +497 -0
  111. package/src/v8/cli/schema/typeToSchema.ts +689 -0
  112. package/src/v8/cli/serve/server.ts +303 -0
  113. package/src/v8/cli/watch.ts +86 -0
  114. package/src/v8/client.ts +147 -0
  115. package/src/v8/cms.ts +237 -0
  116. package/src/v8/content.ts +195 -0
  117. package/src/v8/draft.ts +136 -0
  118. package/src/v8/errors.ts +59 -0
  119. package/src/v8/fetch.ts +152 -0
  120. package/src/v8/identity.ts +65 -0
  121. package/src/v8/index.ts +39 -0
  122. package/src/v8/json.ts +74 -0
  123. package/src/v8/matchRoute.ts +204 -0
  124. package/src/v8/remoteLoader.ts +282 -0
  125. package/src/v8/resolver.ts +278 -0
  126. package/src/v8/secrets.ts +17 -0
  127. package/src/v8/telemetry.ts +533 -0
  128. package/src/v8/types.ts +240 -0
  129. package/src/cms/blockSource.test.ts +0 -76
  130. package/src/cms/client.browserBundle.test.ts +0 -44
  131. package/src/cms/draftSource.test.ts +0 -343
  132. package/src/cms/layoutCacheRace.test.ts +0 -181
  133. package/src/cms/loadDecofileDirectory.test.ts +0 -109
  134. package/src/cms/loader.test.ts +0 -200
  135. package/src/cms/registry.test.ts +0 -110
  136. package/src/cms/resolve.test.ts +0 -980
  137. package/src/cms/schema.test.ts +0 -356
  138. package/src/cms/sectionLoaderContext.test.ts +0 -111
  139. package/src/cms/sectionLoaders.test.ts +0 -533
  140. package/src/cms/sectionMixins.test.ts +0 -167
  141. package/src/cms/stickyFlags.test.ts +0 -117
  142. package/src/flags/flags.test.ts +0 -148
  143. package/src/hooks/Image.test.ts +0 -100
  144. package/src/hooks/RenderSection.test.tsx +0 -81
  145. package/src/matchers/builtins.test.ts +0 -318
  146. package/src/matchers/override.test.ts +0 -205
  147. package/src/middleware/hydrationContext.test.ts +0 -61
  148. package/src/middleware/observability.test.ts +0 -242
  149. package/src/middleware/validateSection.test.ts +0 -147
  150. package/src/sdk/abTesting.test.ts +0 -326
  151. package/src/sdk/cacheHeaders.test.ts +0 -115
  152. package/src/sdk/cachedLoader.test.ts +0 -122
  153. package/src/sdk/cachedLoaderModule.test.ts +0 -209
  154. package/src/sdk/cn.test.ts +0 -34
  155. package/src/sdk/composite.test.ts +0 -121
  156. package/src/sdk/cookie.test.ts +0 -108
  157. package/src/sdk/encoding.test.ts +0 -71
  158. package/src/sdk/env.test.ts +0 -33
  159. package/src/sdk/flags.test.ts +0 -91
  160. package/src/sdk/http.test.ts +0 -71
  161. package/src/sdk/inflightTimeout.test.ts +0 -35
  162. package/src/sdk/instrumentedFetch.test.ts +0 -559
  163. package/src/sdk/invoke.test.ts +0 -115
  164. package/src/sdk/logger.test.ts +0 -432
  165. package/src/sdk/otel.test.ts +0 -526
  166. package/src/sdk/otelAdapters.test.ts +0 -89
  167. package/src/sdk/otelHttpLog.test.ts +0 -457
  168. package/src/sdk/otelHttpMeter.test.ts +0 -292
  169. package/src/sdk/otelHttpTracer.test.ts +0 -474
  170. package/src/sdk/requestContextStorage.browser.test.ts +0 -29
  171. package/src/sdk/urlRedaction.test.ts +0 -73
  172. package/src/sdk/useDevice.test.ts +0 -130
  173. package/src/sdk/useScript.test.ts +0 -128
  174. package/src/sdk/useSuggestions.test.ts +0 -230
  175. package/tsconfig.json +0 -7
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Public types of the next-major (v8) core SDK. See the API reference
3
+ * (`/next/api-reference#types`) — every type here is documented there.
4
+ */
5
+ import type { ReactNode } from "react";
6
+
7
+ // ---------------------------------------------------------------------------
8
+ // Blocks and content
9
+ // ---------------------------------------------------------------------------
10
+
11
+ /**
12
+ * A block as stored: the JSON in `.deco/blocks`, and what `client.list` and
13
+ * `{ run: false }` return. Props never use it: a field's type is the value the
14
+ * function receives.
15
+ */
16
+ export type Block = { __resolveType: string; [input: string]: unknown };
17
+
18
+ /** A function a block can call. */
19
+ export type BlockFunction = (inputs: any) => unknown | Promise<unknown>;
20
+
21
+ /** A block map: what `.deco/index.ts` exports and the CLI reads. */
22
+ export type Blocks = Record<string, BlockFunction>;
23
+
24
+ /** One fixed copy of the content: what the content module exports and `load()` returns. */
25
+ export type Snapshot = {
26
+ revision: string;
27
+ /** The content map: entry name → saved JSON. */
28
+ blocks: Record<string, unknown>;
29
+ /** The alias table `deco content` writes: old type name → your type. */
30
+ aliases?: Record<string, string>;
31
+ };
32
+
33
+ /**
34
+ * The content module `deco content` writes: a snapshot plus `root`, the
35
+ * `.deco` folder it was generated from, which `createCMS` keys its instance
36
+ * on (see /next/api-reference#one-instance-per-process). Not exported.
37
+ */
38
+ export type ContentModule = Snapshot & { root?: string };
39
+
40
+ /** A source of content. `load()` is the release; `load(pointer)` is a draft. */
41
+ export interface Loader {
42
+ load(pointer?: string | null): Promise<Snapshot>;
43
+ update?(): Promise<{ updated: boolean }>;
44
+ }
45
+
46
+ /** The parts of a draft pointer, `<host[:port]><path[?query]>@<version>`. */
47
+ export interface DraftPointer {
48
+ /** `host[:port]` of the content source that holds the draft. */
49
+ host: string;
50
+ /** Starts with `/`; opaque to the app. */
51
+ path: string;
52
+ /** Opaque and immutable: the branch head or ETag. */
53
+ version: string;
54
+ }
55
+
56
+ // ---------------------------------------------------------------------------
57
+ // Built-in types
58
+ // ---------------------------------------------------------------------------
59
+
60
+ /** An entry that lives at a URL. Extend it to make a type routable. */
61
+ export interface Route {
62
+ /** @title Name */
63
+ name: string;
64
+ /** @title Path */
65
+ path: string;
66
+ }
67
+
68
+ export interface Seo {
69
+ title: string;
70
+ description: string;
71
+ }
72
+
73
+ /** The built-in `page` block, resolved: without `seo`, the site's defaults apply. */
74
+ export interface Page extends Route {
75
+ seo?: Seo;
76
+ sections: ReactNode[];
77
+ }
78
+
79
+ /** The built-in `redirect` block. */
80
+ export interface Redirect {
81
+ /** Literal path or template (`:name` segments, an optional trailing `/*`). */
82
+ from: string;
83
+ to: string;
84
+ /** `true` for a 301, `false` for a 302. */
85
+ permanent: boolean;
86
+ /** Wins over `permanent`. */
87
+ status?: RedirectStatus;
88
+ /** Drop the request's query string instead of carrying it over. */
89
+ discardQueryParameters?: boolean;
90
+ }
91
+
92
+ export type RedirectStatus = 301 | 302 | 307 | 308;
93
+
94
+ /**
95
+ * The nested redirect shape v7 content stores (`website/loaders/redirect.ts`).
96
+ * `matchRoute` accepts it next to {@link Redirect}: `permanent` is a 301 and
97
+ * anything else a 307, the status the site editor has always written for it.
98
+ */
99
+ export interface LegacyRedirect {
100
+ redirect: {
101
+ from: string;
102
+ to: string;
103
+ type?: "permanent" | "temporary";
104
+ discardQueryParameters?: boolean;
105
+ };
106
+ }
107
+
108
+ /** A field the site editor saves encrypted, as a `secret` block. */
109
+ export type Secret = string & { readonly __secret: true };
110
+
111
+ /** A prop the built-in `lazy` block fills; resolves its value when called, at most once. */
112
+ export type Lazy<T> = () => Promise<T>;
113
+
114
+ /** One entry of `variants`: a rule and the variant it shows. */
115
+ export interface Variant<T> {
116
+ rule: boolean;
117
+ value: Lazy<T>;
118
+ }
119
+
120
+ /** The `Telemetry` saved block's type (built-in `telemetry`). */
121
+ export interface Telemetry {
122
+ /** Default `true`; `false` switches telemetry off. */
123
+ enabled?: boolean;
124
+ /** Default `true`. */
125
+ metrics?: boolean;
126
+ /** Default 0.05, capped by `telemetry.limits`. */
127
+ errorSampleRate?: number;
128
+ /** Default 0, capped by `telemetry.limits`. */
129
+ traceSampleRate?: number;
130
+ }
131
+
132
+ /** The built-in `analytics` block's props. Separate from telemetry. */
133
+ export interface Analytics {
134
+ /** An endpoint that accepts the One Dollar Stats format; default: the hosted Deco CMS collector. */
135
+ collector?: string;
136
+ /** Default `true`; `false` makes `AnalyticsScript` render nothing. */
137
+ enabled?: boolean;
138
+ }
139
+
140
+ // ---------------------------------------------------------------------------
141
+ // Results and errors
142
+ // ---------------------------------------------------------------------------
143
+
144
+ export type CMSErrorCode =
145
+ | "NOT_FOUND"
146
+ | "UNKNOWN_BLOCK"
147
+ | "CYCLE"
148
+ | "BLOCK_FAILED"
149
+ | "LOADER_FAILED";
150
+
151
+ export interface CMSError {
152
+ code: CMSErrorCode;
153
+ message: string;
154
+ /** Where in the tree it happened, such as `["sections", 2, "product"]`. */
155
+ path: (string | number)[];
156
+ /** The original error, for `BLOCK_FAILED` and `LOADER_FAILED`. */
157
+ cause?: unknown;
158
+ }
159
+
160
+ export type Result<T> = [T, null] | [null, CMSError];
161
+
162
+ // ---------------------------------------------------------------------------
163
+ // Routing
164
+ // ---------------------------------------------------------------------------
165
+
166
+ export type Match<T> =
167
+ | { kind: "match"; entry: T; params: Record<string, string> }
168
+ | { kind: "redirect"; location: string; status: RedirectStatus }
169
+ | { kind: "not-found" };
170
+
171
+ // ---------------------------------------------------------------------------
172
+ // The CMS and its clients
173
+ // ---------------------------------------------------------------------------
174
+
175
+ export type TelemetryConfig = (
176
+ | { site: string; token: string }
177
+ | { endpoint: string; headers?: Record<string, string> }
178
+ ) & {
179
+ limits?: { errorSampleRate?: number; traceSampleRate?: number };
180
+ };
181
+
182
+ export interface CMSConfig {
183
+ /** Your block functions; the CMS uses `{ ...builtIns, ...blocks }`. */
184
+ blocks: Blocks;
185
+ /** The content module (`.deco/blocks.gen.ts`), or any {@link Loader}. */
186
+ content: ContentModule | Loader;
187
+ /** ms between `update()` checks of a content source that has one; minimum 60 000. */
188
+ interval?: number;
189
+ /** Where telemetry goes; see /next/telemetry. */
190
+ telemetry?: false | TelemetryConfig;
191
+ /** The private key that decrypts `secret` blocks. */
192
+ secrets?: { key?: string };
193
+ /** Your site's ID, for hosted releases and drafts. */
194
+ site?: string;
195
+ /** Your site token (secret), for hosted releases and drafts. */
196
+ token?: string;
197
+ }
198
+
199
+ export interface ResolveOptions {
200
+ /** `false` reads without running: saved blocks expand, no function runs. */
201
+ run?: boolean;
202
+ }
203
+
204
+ export interface ListOptions<T> {
205
+ where?: (entry: T) => boolean;
206
+ sort?: (a: T, b: T) => number;
207
+ limit?: number;
208
+ run?: boolean;
209
+ }
210
+
211
+ /**
212
+ * Reads one revision for one request.
213
+ *
214
+ * Results are read-only. A client runs each block function once per distinct
215
+ * input, so the same block at two places in a request hands both places the
216
+ * same object; mutating it in place changes the other occurrence too. Copy a
217
+ * result before changing it. (The memo belongs to one client, so nothing is
218
+ * shared across requests.)
219
+ */
220
+ export interface Client {
221
+ resolve<T = unknown>(target: unknown, options?: ResolveOptions): Promise<Result<T>>;
222
+ list<T = Block>(type: string, options?: ListOptions<T>): Promise<Result<T[]>>;
223
+ /**
224
+ * The revision this client reads (loads it on first use). Unlike `resolve`
225
+ * and `list`, it rejects with the `LOADER_FAILED` error when the content
226
+ * can't load, since there is no revision to report.
227
+ */
228
+ revision(): Promise<string>;
229
+ }
230
+
231
+ export interface CMS {
232
+ /** A client reading the current release. */
233
+ forRelease(): Client;
234
+ /** A client reading the draft a pointer names. */
235
+ forDraft(pointer: string): Client;
236
+ /** A client pinned to a revision this CMS has served; an unknown revision behaves like the release. */
237
+ forRevision(revision: string): Client;
238
+ /** Ask the content source for newer content now; never throws. */
239
+ update(): Promise<{ updated: boolean }>;
240
+ }
@@ -1,76 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { djb2Hex } from "../sdk/djb2";
3
- import {
4
- BundledBlockSource,
5
- computeRevision,
6
- DEPLOYMENTS_KEY,
7
- type KVNamespace,
8
- LIVE_KEY,
9
- revisionKey,
10
- snapshotKey,
11
- } from "./blockSource";
12
-
13
- describe("computeRevision", () => {
14
- it("matches loader.ts computeRevision (djb2Hex of JSON.stringify)", () => {
15
- const blocks = { Site: { name: "x" }, "pages-home": { path: "/" } };
16
- expect(computeRevision(blocks)).toBe(djb2Hex(JSON.stringify(blocks)));
17
- });
18
-
19
- it("is stable for the same input and differs on change", () => {
20
- const a = { a: 1 };
21
- const b = { a: 2 };
22
- expect(computeRevision(a)).toBe(computeRevision(a));
23
- expect(computeRevision(a)).not.toBe(computeRevision(b));
24
- });
25
-
26
- it("hashes an empty decofile without throwing", () => {
27
- expect(typeof computeRevision({})).toBe("string");
28
- });
29
- });
30
-
31
- describe("BundledBlockSource", () => {
32
- it("loadSnapshot resolves null (bundled is applied at startup, not here)", async () => {
33
- const src = new BundledBlockSource();
34
- await expect(src.loadSnapshot()).resolves.toBeNull();
35
- });
36
-
37
- it("getRevision resolves null", async () => {
38
- const src = new BundledBlockSource();
39
- await expect(src.getRevision()).resolves.toBeNull();
40
- });
41
- });
42
-
43
- describe("KV key layout (per deployment)", () => {
44
- it("keys the snapshot and revision by deployment id", () => {
45
- expect(snapshotKey("abc123")).toBe("decofile:abc123");
46
- expect(revisionKey("abc123")).toBe("index:revision:abc123");
47
- });
48
-
49
- it("exposes stable pointer/bookkeeping keys", () => {
50
- expect(LIVE_KEY).toBe("index:live");
51
- expect(DEPLOYMENTS_KEY).toBe("index:deployments");
52
- });
53
- });
54
-
55
- describe("KVNamespace structural type", () => {
56
- it("a plain Map-backed stub satisfies the interface", async () => {
57
- const store = new Map<string, string>();
58
- const kv: KVNamespace = {
59
- get: (k) => Promise.resolve(store.get(k) ?? null),
60
- put: (k, v) => {
61
- store.set(k, v);
62
- return Promise.resolve();
63
- },
64
- delete: (k) => {
65
- store.delete(k);
66
- return Promise.resolve();
67
- },
68
- };
69
-
70
- const key = revisionKey("abc123");
71
- await kv.put(key, "abc");
72
- await expect(kv.get(key)).resolves.toBe("abc");
73
- await kv.delete(key);
74
- await expect(kv.get(key)).resolves.toBeNull();
75
- });
76
- });
@@ -1,44 +0,0 @@
1
- import { execFileSync } from "node:child_process";
2
- import { dirname, join } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { describe, expect, it } from "vitest";
5
-
6
- const here = dirname(fileURLToPath(import.meta.url));
7
- // esbuild's JS API relies on `new TextEncoder().encode("") instanceof
8
- // Uint8Array` internally, which fails across Vitest's module-isolation VM
9
- // boundary (a realm mismatch, not a real environment problem — `bun -e`
10
- // confirms the invariant holds outside Vitest). Shelling out to the esbuild
11
- // CLI binary sidesteps this: it's a separate OS process, no shared JS realm.
12
- const esbuildBin = join(here, "../../../../node_modules/.bin/esbuild");
13
-
14
- function bundleForBrowser(entry: string) {
15
- return execFileSync(
16
- esbuildBin,
17
- [entry, "--bundle", "--platform=browser", "--format=esm", "--external:react"],
18
- { encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] },
19
- );
20
- }
21
-
22
- /**
23
- * Regression test for the bug that motivated splitting `client.ts` out of
24
- * `index.ts`: importing ANYTHING from the full `cms` barrel forces a
25
- * bundler to evaluate `loader.ts` and `middleware/observability.ts`, which
26
- * import `node:async_hooks` at the module level. Turbopack rejects that
27
- * outright when bundling for a browser target; this test catches the same
28
- * class of failure in CI, deterministically, without needing a real Next.js
29
- * app to reproduce it.
30
- */
31
- describe("cms/client browser bundle", () => {
32
- it("bundles for a browser target with no Node built-ins", () => {
33
- const output = bundleForBrowser(join(here, "client.ts"));
34
- expect(output).not.toMatch(/node:async_hooks|node:fs|node:path/);
35
- });
36
-
37
- it("sanity check: the full cms barrel does NOT bundle for a browser target", () => {
38
- // Confirms the test above is actually discriminating — if this ever
39
- // stops throwing, either the barrel no longer has the leak (great,
40
- // update this test) or esbuild's Node-builtin detection changed
41
- // (investigate before trusting the test above).
42
- expect(() => bundleForBrowser(join(here, "index.ts"))).toThrow();
43
- });
44
- });