Open History to see the last commit
1// @effect-diagnostics nodeBuiltinImport:off - compiles real source files on disk.
2import * as NodeFS from "node:fs";
3import * as NodePath from "node:path";
4import * as NodeURL from "node:url";
5import { transform } from "oxc-transform-react";
6import { describe, expect, it } from "vite-plus/test";
7
8const repoRoot = NodePath.resolve(
9 NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)),
10 "../../..",
11);
12
13const webSourceFiles = NodeFS.readdirSync(NodePath.join(repoRoot, "apps/web/src"), {
14 recursive: true,
15})
16 .map(String)
17 .filter((file) => /\.tsx?$/.test(file) && !/\.(test|browser)\.tsx?$/.test(file))
18 .filter((file) => !file.endsWith(".gen.ts"))
19 .map((file) => `apps/web/src/${file}`);
20
21// Lint reports most compiler bailouts, but not every one (try/finally, throw
22// inside try). A skipped file still builds, just unmemoized, so check the output.
23describe("React Compiler coverage", () => {
24 it.each(webSourceFiles)("compiles %s", async (file) => {
25 const absolute = NodePath.join(repoRoot, file);
26 const result = await transform(absolute, NodeFS.readFileSync(absolute, "utf8"), {
27 jsx: { runtime: "automatic", development: false, refresh: false },
28 reactCompiler: { reportDiagnostics: true },
29 });
30 const bailouts = result.errors.map((error) => error.codeframe ?? error.message);
31 expect(bailouts).toEqual([]);
32 });
33});