Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tests/root-tsconfig.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import path from "node:path";
import ts from "typescript";
import { describe, expect, it } from "vite-plus/test";

const repoRoot = path.resolve(import.meta.dirname, "..");
const rootTsconfig = path.join(repoRoot, "tsconfig.json");

function loadRootTsconfigFileNames(): string[] {
const config = ts.readConfigFile(rootTsconfig, (fileName) => ts.sys.readFile(fileName));
if (config.error) {
throw new Error(ts.flattenDiagnosticMessageText(config.error.messageText, "\n"));
}

const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, repoRoot);
if (parsed.errors.length > 0) {
throw new Error(
parsed.errors
.map((error) => ts.flattenDiagnosticMessageText(error.messageText, "\n"))
.join("\n"),
);
}

return parsed.fileNames.map((fileName) =>
path.relative(repoRoot, fileName).replaceAll(path.sep, "/"),
);
}

describe("root tsconfig scope", () => {
it("keeps independent app files and package build output outside the root project", () => {
const fileNames = loadRootTsconfigFileNames();

expect(fileNames).toContain("packages/vinext/src/index.ts");
expect(fileNames).toContain("tests/root-tsconfig.test.ts");
expect(fileNames).toContain("vite.config.ts");
expect(fileNames.some((fileName) => fileName.startsWith("apps/"))).toBe(false);
expect(fileNames.some((fileName) => fileName.startsWith("packages/vinext/dist/"))).toBe(false);
expect(fileNames.some((fileName) => fileName.startsWith(".claude/"))).toBe(false);
expect(fileNames.some((fileName) => fileName.startsWith(".worktrees/"))).toBe(false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions .refs/ as a directory that existed and caused issues during formatting. It's gitignored (or at least not committed), but if someone has it locally, include already keeps it out. If you wanted to be thorough, you could add a .refs/ assertion here too — but it's a truly optional polish since the directory isn't in the repo.

Comment on lines +35 to +38
Copy link
Copy Markdown
Collaborator

@james-elicx james-elicx May 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dist entries should already be excluded. you can add .claude, .worktrees, .nextjs-ref, etc. to exclude if you want? otherwise, i'd rather it includes everything in the repo and excludes stuff that isn't part of the repo. there is also no need for a test file for this.

});
});
8 changes: 8 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,13 @@
"vinext/shims/*": ["./packages/vinext/src/shims/*"]
}
},
"include": [
"*.ts",
"*.tsx",
"packages/vinext/src/**/*.ts",
"packages/vinext/src/**/*.tsx",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": ["node_modules", "dist", "fixtures", "tests/fixtures", "benchmarks", "examples"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: With an explicit include, most of the exclude entries are now redundant — node_modules, dist, fixtures, benchmarks, and examples are already outside the include globs. The only entry that still does work is tests/fixtures (since tests/**/*.ts would otherwise pull in fixture files).

Not a blocker — the extra excludes are harmless as defense-in-depth — but if you want to tidy this up later, the exclude could be trimmed to just ["tests/fixtures"].

}
Loading