@akanjs/devkit 3.0.0-beta.25 → 3.0.0-beta.27

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 (34) hide show
  1. package/DEV_RUNTIME_KNOBS.md +9 -6
  2. package/akanApp/akanApp.host.ts +79 -22
  3. package/akanApp/devHostPolicy.test.ts +56 -11
  4. package/akanApp/devHostPolicy.ts +10 -10
  5. package/csrE2e/csrE2eHarness.fixture.ts +55 -5
  6. package/csrE2e/csrRootLayout.e2e.test.ts +134 -0
  7. package/csrE2e/registryVendor.e2e.test.ts +221 -0
  8. package/frontendBuild/clientEntryDiscovery.test.ts +75 -0
  9. package/frontendBuild/clientEntryDiscovery.ts +112 -70
  10. package/frontendBuild/csrDevArtifactWriter.test.ts +8 -0
  11. package/frontendBuild/csrDevArtifactWriter.ts +4 -0
  12. package/frontendBuild/csrDevBundler.ts +1 -1
  13. package/frontendBuild/csrDevFactoryCheck.test.ts +33 -0
  14. package/frontendBuild/csrDevFactoryCheck.ts +39 -0
  15. package/frontendBuild/csrDevModuleCompiler.test.ts +261 -0
  16. package/frontendBuild/csrDevModuleCompiler.ts +95 -20
  17. package/frontendBuild/csrDevPatcher.test.ts +234 -2
  18. package/frontendBuild/csrDevPatcher.ts +184 -10
  19. package/frontendBuild/csrDevPaths.ts +32 -11
  20. package/frontendBuild/csrDevResolver.test.ts +76 -2
  21. package/frontendBuild/csrDevResolver.ts +141 -12
  22. package/frontendBuild/csrDevTypes.ts +2 -0
  23. package/frontendBuild/devRegistryBundler.ts +18 -3
  24. package/frontendBuild/ssrDevBundler.ts +2 -8
  25. package/incrementalBuilder/incrementalBuilder.host.test.ts +34 -0
  26. package/incrementalBuilder/incrementalBuilder.host.ts +18 -3
  27. package/incrementalBuilder/incrementalBuilder.proc.test.ts +62 -1
  28. package/incrementalBuilder/incrementalBuilder.proc.ts +58 -24
  29. package/integration/devStability.integration.test.ts +9 -2
  30. package/mobile/nativeApp.test.ts +15 -0
  31. package/mobile/nativeApp.ts +54 -14
  32. package/mobile/nativeAppLine.test.ts +62 -0
  33. package/mobile/nativeAppLine.ts +63 -0
  34. package/package.json +2 -2
@@ -0,0 +1,134 @@
1
+ import { afterAll, beforeAll, describe, expect, test } from "bun:test";
2
+ import { CsrE2eHarness } from "./csrE2eHarness.fixture";
3
+
4
+ //* Where a CSR page lands, not only what its console says. CSR's root layout renders the pages in a frame of its own
5
+ //* and hides what it wraps, so a layout the route table puts at the root wraps no page: an app with its root layout
6
+ //* in a route group once rendered nothing, then rendered its dashboard outside the lock screen that wraps it.
7
+ const EXPLORE = "/explore";
8
+ const TAB_A = "/e2e/stack/tab-a";
9
+ //? The web layout draws no bottom chrome, so the `(tab)` layout shows in the route table, not in the text.
10
+ const exploreText = ["Where are you headed today?", "Popular stays right now"];
11
+
12
+ interface RouteTableWindow {
13
+ __akan?: { inspect(): { executed: string[] }; require(id: string): unknown };
14
+ }
15
+
16
+ //? A page's element is inside its layout's marker, outside the hidden provider container, and on screen.
17
+ const placement = async (harness: CsrE2eHarness, page: string) =>
18
+ await harness.evaluate((selector: string) => {
19
+ const element = document.querySelector(selector);
20
+ return {
21
+ rendered: element !== null,
22
+ inLayout: element?.closest('[data-e2e="public-layout"]') != null,
23
+ hidden: element?.closest("#csr-provider-children") != null,
24
+ visible: element?.checkVisibility() ?? false,
25
+ };
26
+ }, `[data-e2e="${page}"]`);
27
+
28
+ describe.skipIf(!CsrE2eHarness.enabled)("CSR layouts under a root layout (minimal, (tab))", () => {
29
+ let csr: CsrE2eHarness;
30
+
31
+ beforeAll(async () => {
32
+ csr = await CsrE2eHarness.start({
33
+ app: "minimal",
34
+ port: Number(process.env.AKAN_CSR_E2E_ROOT_LAYOUT_PORT ?? 8497),
35
+ });
36
+ }, 240_000);
37
+
38
+ afterAll(async () => {
39
+ // biome-ignore lint/suspicious/noUnnecessaryConditions: unassigned when beforeAll threw before the harness started
40
+ await csr?.close();
41
+ }, 60_000);
42
+
43
+ const rendered = async (texts: string[]) =>
44
+ await csr.waitFor(
45
+ (want: string[]) => want.every((text) => (document.getElementById("root")?.innerText ?? "").includes(text)),
46
+ { args: [texts], timeout: 30_000 },
47
+ );
48
+ //? The table the running bundle built, read through the dev registry: what the router renders from.
49
+ const layerCounts = async () =>
50
+ await csr.evaluate(() => {
51
+ const akan = (window as unknown as RouteTableWindow).__akan;
52
+ const id = akan?.inspect().executed.find((executed) => executed.endsWith("webkit/CsrRouteTable.ts"));
53
+ const table = id
54
+ ? (akan?.require(id) as {
55
+ CsrRouteTable: {
56
+ active: {
57
+ snapshot(): { pathRoutes: { path: string; renderRootLayouts: unknown[]; renderLayouts: unknown[] }[] };
58
+ };
59
+ };
60
+ })
61
+ : null;
62
+ return Object.fromEntries(
63
+ (table?.CsrRouteTable.active.snapshot().pathRoutes ?? []).map((route) => [
64
+ route.path,
65
+ { root: route.renderRootLayouts.length, layouts: route.renderLayouts.length },
66
+ ]),
67
+ );
68
+ });
69
+
70
+ test("a nested root boundary renders with its pages, not at the root", async () => {
71
+ await csr.open(EXPLORE);
72
+ await rendered(exploreText);
73
+ const counts = await layerCounts();
74
+ expect(counts["/:lang/explore"]?.root).toBe(counts["/:lang/e2e/stack/tab-a"]?.root);
75
+ expect(counts["/:lang/explore"]?.layouts).toBe(1);
76
+ expect(csr.consoleMessages().filter((message) => /no root layout|error occurred/.test(message))).toEqual([]);
77
+ }, 60_000);
78
+
79
+ test("leaving the group and coming back renders each side", async () => {
80
+ await csr.open(EXPLORE);
81
+ await rendered(exploreText);
82
+ await csr.navigate(TAB_A);
83
+ await csr.waitFor(() => document.querySelector('[data-e2e-probe="tab-a"]') !== null, { timeout: 30_000 });
84
+ await csr.back();
85
+ await rendered(exploreText);
86
+ }, 90_000);
87
+ });
88
+
89
+ describe.skipIf(!CsrE2eHarness.enabled)("a root layout in a route group (groupedroot, page/(app)/_layout)", () => {
90
+ let harness: CsrE2eHarness;
91
+
92
+ beforeAll(async () => {
93
+ harness = await CsrE2eHarness.start({
94
+ app: "groupedroot",
95
+ port: Number(process.env.AKAN_CSR_E2E_GROUPED_ROOT_PORT ?? 8498),
96
+ });
97
+ }, 240_000);
98
+
99
+ afterAll(async () => {
100
+ // biome-ignore lint/suspicious/noUnnecessaryConditions: unassigned when beforeAll threw before the harness started
101
+ await harness?.close();
102
+ }, 60_000);
103
+
104
+ const open = async (path: string, page: string, csr: boolean) => {
105
+ await harness.open(path, { csr });
106
+ await harness.waitFor((selector: string) => document.querySelector(selector) !== null, {
107
+ args: [`[data-e2e="${page}"]`],
108
+ timeout: 30_000,
109
+ });
110
+ };
111
+
112
+ test.each([
113
+ ["SSR", false],
114
+ ["CSR", true],
115
+ ] as const)(
116
+ "%s: a page renders inside the (public) layout that wraps it",
117
+ async (_mode, csr) => {
118
+ for (const [path, page] of [
119
+ ["/dashboard", "dashboard"],
120
+ ["/", "index"],
121
+ ] as const) {
122
+ await open(path, page, csr);
123
+ expect(await placement(harness, page)).toEqual({
124
+ rendered: true,
125
+ inLayout: true,
126
+ hidden: false,
127
+ visible: true,
128
+ });
129
+ }
130
+ expect(harness.consoleMessages().filter((message) => /no root layout|error occurred/.test(message))).toEqual([]);
131
+ },
132
+ 90_000,
133
+ );
134
+ });
@@ -0,0 +1,221 @@
1
+ import { afterAll, beforeAll, describe, expect, test } from "bun:test";
2
+ import { rm } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { CsrE2eHarness } from "./csrE2eHarness.fixture";
5
+
6
+ //* Package shapes that once turned a whole dev vendor file into a SyntaxError or a startup throw, each followed by
7
+ //* nothing but distant MissingModuleErrors. Written in for the run only: no app of the repo depends on them.
8
+ const workspaceRoot = path.resolve(import.meta.dir, "../../../..");
9
+ const vendorRoot = path.join(workspaceRoot, "node_modules/@akan-e2e");
10
+ const probeFile = path.join(workspaceRoot, "apps/minimal/ui/RegistryVendor.tsx");
11
+ const pageFile = path.join(workspaceRoot, "apps/minimal/page/(home)/e2e/vendor.tsx");
12
+ const cliFile = path.join(workspaceRoot, "dist/pkgs/@akanjs/cli/index.js");
13
+ const VENDOR = "/e2e/vendor";
14
+ const expected = { prebundled: 3, metaDev: true, metaUrl: "http:", used: "used", inspectish: "yes" };
15
+ const broken =
16
+ /SyntaxError|MissingModuleError|no module registered|Node built-in|left out of the dev registry|error occurred in one of your React components/;
17
+
18
+ const packages: Record<string, string> = {
19
+ //? esbuild's own interop helpers, as the @mermaid-js/parser chunks ship them.
20
+ "prebundled/package.json": JSON.stringify({ name: "@akan-e2e/prebundled", type: "module", main: "chunk.mjs" }),
21
+ "prebundled/chunk.mjs": `var __create = Object.create;
22
+ var __defProp = Object.defineProperty;
23
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
24
+ var __getOwnPropNames = Object.getOwnPropertyNames;
25
+ var __getProtoOf = Object.getPrototypeOf;
26
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
37
+ var parts = {};
38
+ __reExport(parts, { a: 1 });
39
+ var wrapped = __toESM({ b: 2 });
40
+ export const prebundled = parts.a + wrapped.b;
41
+ `,
42
+ //? jotai's and zustand's ESM development check.
43
+ "meta-env/package.json": JSON.stringify({
44
+ name: "@akan-e2e/meta-env",
45
+ type: "module",
46
+ exports: { ".": "./esm/index.mjs" },
47
+ }),
48
+ "meta-env/esm/index.mjs": `export const metaDev = (import.meta.env ? import.meta.env.MODE : void 0) !== "production";
49
+ export const metaUrl = new URL(import.meta.url).protocol;
50
+ `,
51
+ //? vfile behind unified: a side-effect-free barrel whose unused re-exports reach Node-only files through `#imports`.
52
+ "barrel/package.json": JSON.stringify({
53
+ name: "@akan-e2e/barrel",
54
+ type: "module",
55
+ main: "index.js",
56
+ sideEffects: false,
57
+ imports: {
58
+ "#where": { node: "./where.node.js", default: "./where.browser.js" },
59
+ "#other": { node: "./other.node.js", default: "./other.browser.js" },
60
+ },
61
+ }),
62
+ "barrel/index.js": `export { used } from "./used.js";
63
+ export { unused } from "./unused.js";
64
+ export { other } from "#other";
65
+ `,
66
+ "barrel/used.js": `export const used = "used";\n`,
67
+ "barrel/unused.js": `import { where } from "#where";\nexport const unused = where;\n`,
68
+ "barrel/where.node.js": `import path from "node:path";\nexport const where = path.sep;\n`,
69
+ "barrel/where.browser.js": `export const where = "browser";\n`,
70
+ "barrel/other.node.js": `import path from "node:path";\nexport const other = path.sep;\n`,
71
+ "barrel/other.browser.js": `export const other = "browser";\n`,
72
+ //? object-inspect: a `browser` map that turns a Node-only file off.
73
+ "inspectish/package.json": JSON.stringify({
74
+ name: "@akan-e2e/inspectish",
75
+ main: "index.js",
76
+ browser: { "./util.inspect.js": false },
77
+ }),
78
+ //? Bun's own bundle gives the require `() => ({})` where the registry gives `{}`; either way it must not throw.
79
+ "inspectish/index.js": `var inspect = require("./util.inspect");\nmodule.exports = { loaded: inspect ? "yes" : "no" };\n`,
80
+ "inspectish/util.inspect.js": `module.exports = require("util").inspect;\n`,
81
+ };
82
+
83
+ const probeSource = `"use client";
84
+ import { used } from "@akan-e2e/barrel";
85
+ import inspectish from "@akan-e2e/inspectish";
86
+ import { metaDev, metaUrl } from "@akan-e2e/meta-env";
87
+ import { prebundled } from "@akan-e2e/prebundled";
88
+ import { useEffect, useState } from "react";
89
+
90
+ export const RegistryVendor = () => {
91
+ const [hydrated, setHydrated] = useState(false);
92
+ useEffect(() => setHydrated(true), []);
93
+ return (
94
+ <div data-e2e="vendor" data-e2e-hydrated={hydrated ? "1" : "0"} data-e2e-hot="0">
95
+ {JSON.stringify({ prebundled, metaDev, metaUrl, used, inspectish: inspectish.loaded })}
96
+ </div>
97
+ );
98
+ };
99
+ `;
100
+
101
+ const pageSource = `import { page } from "akanjs/client";
102
+ import { RegistryVendor } from "../../../ui/RegistryVendor";
103
+
104
+ export default page()
105
+ .config({ transition: "none", gesture: false })
106
+ .render(() => (
107
+ <main>
108
+ <RegistryVendor />
109
+ </main>
110
+ ));
111
+ `;
112
+
113
+ interface VendorWindow {
114
+ __akan?: { has(id: string): boolean; inspect(): { started: boolean; failed: boolean; executed: string[] } };
115
+ }
116
+
117
+ describe.skipIf(!CsrE2eHarness.enabled)("dev registries with the package shapes that broke them (minimal)", () => {
118
+ //? Run first too, and safe to run twice: a run killed mid-way (a timeout, SIGKILL, a Jenkins abort on a reused
119
+ //? workspace) leaves the packages, the probe and the page behind, and `akan sync` rebuilds the barrel it joined.
120
+ const cleanup = async () => {
121
+ await Promise.all([
122
+ rm(vendorRoot, { recursive: true, force: true }),
123
+ rm(probeFile, { force: true }),
124
+ rm(pageFile, { force: true }),
125
+ ]);
126
+ for (const command of [
127
+ ["bun", path.join(workspaceRoot, "pkgs/@akanjs/cli/build.ts")],
128
+ ["bun", cliFile, "sync", "minimal"],
129
+ ]) {
130
+ const done = Bun.spawnSync(command, { cwd: workspaceRoot, stdout: "ignore" });
131
+ if (done.exitCode !== 0)
132
+ throw new Error(`[csr-e2e] ${command.slice(1).join(" ")} failed: ${done.stderr.toString()}`);
133
+ }
134
+ };
135
+
136
+ beforeAll(async () => {
137
+ await cleanup();
138
+ for (const [file, text] of Object.entries(packages)) await Bun.write(path.join(vendorRoot, file), text);
139
+ await Bun.write(probeFile, probeSource);
140
+ await Bun.write(pageFile, pageSource);
141
+ }, 120_000);
142
+
143
+ afterAll(cleanup, 120_000);
144
+
145
+ describe.each([
146
+ ["registry", 8495],
147
+ ["artifact", 8496],
148
+ ] as const)("AKAN_DEV_CSR=%s", (mode, port) => {
149
+ let harness: CsrE2eHarness;
150
+
151
+ beforeAll(async () => {
152
+ harness = await CsrE2eHarness.start({ app: "minimal", port, env: { AKAN_DEV_CSR: mode } });
153
+ }, 240_000);
154
+
155
+ afterAll(async () => {
156
+ // biome-ignore lint/suspicious/noUnnecessaryConditions: unassigned when beforeAll threw before the harness started
157
+ await harness?.close();
158
+ }, 60_000);
159
+
160
+ const probeValues = async () =>
161
+ JSON.parse((await harness.text('[data-e2e="vendor"]', { mounted: true }))[0] ?? "null") as typeof expected | null;
162
+ const openVendor = async (csr: boolean) => {
163
+ await harness.open(VENDOR, { csr });
164
+ await harness.waitFor(
165
+ () => document.querySelector('[data-e2e="vendor"]')?.getAttribute("data-e2e-hydrated") === "1",
166
+ { timeout: 60_000 },
167
+ );
168
+ };
169
+ const registryState = async () =>
170
+ await harness.evaluate(() => {
171
+ const akan = (window as unknown as VendorWindow).__akan;
172
+ if (!akan) return null;
173
+ const { started, failed, executed } = akan.inspect();
174
+ return {
175
+ started,
176
+ failed,
177
+ refresh: executed.some((id) => id.includes("react-refresh/")),
178
+ vendors: [
179
+ "node_modules/@akan-e2e/prebundled/chunk.mjs",
180
+ "node_modules/@akan-e2e/meta-env/esm/index.mjs",
181
+ "node_modules/@akan-e2e/barrel/unused.js",
182
+ "node_modules/@akan-e2e/inspectish/index.js",
183
+ ].filter((id) => akan.has(id)),
184
+ };
185
+ });
186
+
187
+ test("an SSR page hydrates its client code with every package shape in it", async () => {
188
+ await openVendor(false);
189
+ expect(await probeValues()).toEqual(expected);
190
+ expect(await registryState()).toMatchObject({ started: true, failed: false });
191
+ expect((await registryState())?.vendors).toHaveLength(4);
192
+ expect(harness.consoleMessages().filter((message) => broken.test(message))).toEqual([]);
193
+ }, 120_000);
194
+
195
+ test("a CSR page boots and renders with every package shape in it", async () => {
196
+ await openVendor(true);
197
+ expect(await probeValues()).toEqual(expected);
198
+ const state = await registryState();
199
+ if (mode === "registry") expect(state).toMatchObject({ started: true, failed: false, refresh: true });
200
+ if (mode === "registry") expect(state?.vendors).toHaveLength(4);
201
+ expect(harness.consoleMessages().filter((message) => broken.test(message))).toEqual([]);
202
+ }, 120_000);
203
+
204
+ test("a save to the page's client code shows on the CSR page", async () => {
205
+ await openVendor(true);
206
+ await harness.editSource(
207
+ probeFile,
208
+ (source) => source.replace('data-e2e-hot="0"', 'data-e2e-hot="1"'),
209
+ async () => {
210
+ await harness.waitFor(
211
+ () => document.querySelector('[data-e2e="vendor"]')?.getAttribute("data-e2e-hot") === "1",
212
+ { timeout: 60_000 },
213
+ );
214
+ },
215
+ );
216
+ //? The registry patches in place; the single-file artifact reloads on every save, which is its contract.
217
+ expect(await harness.reloaded()).toBe(mode === "artifact");
218
+ expect(await probeValues()).toEqual(expected);
219
+ }, 120_000);
220
+ });
221
+ });
@@ -34,4 +34,79 @@ describe("GraphClientEntryDiscovery", () => {
34
34
  expect(await discovery.discover([file("S.tsx")])).toEqual([file("C.tsx")]);
35
35
  }
36
36
  });
37
+
38
+ const tempDir = async () => {
39
+ const dir = await mkdtemp(path.join(os.tmpdir(), "akan-discovery-"));
40
+ dirs.push(dir);
41
+ return (name: string) => path.join(dir, name);
42
+ };
43
+
44
+ test("an entry moved into a folder, or to another extension, is found once the move is invalidated", async () => {
45
+ const file = await tempDir();
46
+ await Bun.write(file("S.tsx"), 'import "./ui/Chart";\nimport "./ui/Card";\n');
47
+ await Bun.write(file("ui/Chart.tsx"), '"use client";\nexport const Chart = () => null;\n');
48
+ await Bun.write(file("ui/Card.tsx"), '"use client";\nexport const Card = () => null;\n');
49
+ const discovery = new GraphClientEntryDiscovery({ barrelImports: [] }, (async () => null) as never);
50
+ expect(await discovery.discover([file("S.tsx")])).toEqual([file("ui/Card.tsx"), file("ui/Chart.tsx")]);
51
+
52
+ await rm(file("ui/Chart.tsx"));
53
+ await Bun.write(file("ui/Chart/index.tsx"), '"use client";\nexport const Chart = () => null;\n');
54
+ await rm(file("ui/Card.tsx"));
55
+ await Bun.write(file("ui/Card.ts"), '"use client";\nexport const Card = () => null;\n');
56
+ discovery.invalidate([file("ui/Chart.tsx"), file("ui/Chart/index.tsx"), file("ui/Card.tsx"), file("ui/Card.ts")]);
57
+ expect(await discovery.discover([file("S.tsx")])).toEqual([file("ui/Card.ts"), file("ui/Chart/index.tsx")]);
58
+ });
59
+
60
+ test("a resolution still in flight when its target appears is not what the next walk reads", async () => {
61
+ const file = await tempDir();
62
+ await Bun.write(file("S.tsx"), 'import "./B";\n');
63
+ await Bun.write(file("B.tsx"), 'import "@demo/C";\nexport const b = 1;\n');
64
+ const gate = Promise.withResolvers<void>();
65
+ const seen = Promise.withResolvers<void>();
66
+ let calls = 0;
67
+ const resolvePackage = async () => {
68
+ calls += 1;
69
+ const exists = await Bun.file(file("C.tsx")).exists();
70
+ if (calls === 1) {
71
+ seen.resolve();
72
+ await gate.promise;
73
+ }
74
+ return exists ? { entryFile: file("C.tsx") } : null;
75
+ };
76
+ const discovery = new GraphClientEntryDiscovery({ barrelImports: [] }, resolvePackage as never);
77
+ const walk = discovery.discover([file("S.tsx")]);
78
+ await seen.promise;
79
+ await Bun.write(file("C.tsx"), '"use client";\nexport const C = () => null;\n');
80
+ discovery.invalidate([file("C.tsx")]);
81
+ gate.resolve();
82
+ await walk;
83
+ expect(await discovery.discover([file("S.tsx")])).toEqual([file("C.tsx")]);
84
+ });
85
+
86
+ test("a dense import cycle is walked once per file, not once per path", async () => {
87
+ const file = await tempDir();
88
+ const names = Array.from({ length: 12 }, (_, idx) => `M${idx}.tsx`);
89
+ for (const name of names)
90
+ await Bun.write(file(name), names.map((other) => `import "./${other.replace(".tsx", "")}";\n`).join(""));
91
+ await Bun.write(file("C.tsx"), '"use client";\nexport const C = () => null;\n');
92
+ await Bun.write(
93
+ file("M11.tsx"),
94
+ `${names.map((other) => `import "./${other.replace(".tsx", "")}";\n`).join("")}import "./C";\n`,
95
+ );
96
+ const discovery = new GraphClientEntryDiscovery({ barrelImports: [] }, (async () => null) as never);
97
+ const started = performance.now();
98
+ expect(await discovery.discover([file("M0.tsx")])).toEqual([file("C.tsx")]);
99
+ expect(performance.now() - started).toBeLessThan(2_000);
100
+ expect(await discovery.discover([file("M5.tsx")])).toEqual([file("C.tsx")]);
101
+ });
102
+
103
+ test("a file walked inside an import cycle keeps no partial result for a walk that starts at it", async () => {
104
+ const file = await tempDir();
105
+ await Bun.write(file("A.tsx"), 'import "./B";\nimport "./C";\n');
106
+ await Bun.write(file("B.tsx"), 'import "./A";\n');
107
+ await Bun.write(file("C.tsx"), '"use client";\nexport const C = () => null;\n');
108
+ const discovery = new GraphClientEntryDiscovery({ barrelImports: [] }, (async () => null) as never);
109
+ expect(await discovery.discover([file("A.tsx")])).toEqual([file("C.tsx")]);
110
+ expect(await discovery.discover([file("B.tsx")])).toEqual([file("C.tsx")]);
111
+ });
37
112
  });