Keep test-only source out of the published build - #218
Conversation
The tsconfig exclude pointed at a stale path (src/server/tools/test-helpers.ts), so the real file (src/core/server/tools/test-helpers.ts) and the *.compile-test.ts brand guards were compiled into dist/ and shipped in the package. Split the build config from the typecheck config: tsconfig.build.json excludes all test code by pattern (won't rot if files move), while the base tsconfig still type-checks the compile-test guards. build/build:watch now use -p tsconfig.build.json. Adds a regression test that asks tsc which files the build config compiles and fails if any test module survives.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR adds ChangesBuild configuration and validation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #218 +/- ##
=======================================
Coverage ? 85.07%
=======================================
Files ? 46
Lines ? 2399
Branches ? 826
=======================================
Hits ? 2041
Misses ? 357
Partials ? 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…in sync Cross-reference tsconfig.build.json's exclude and the TEST_CODE regexes in build-excludes-test-code.test.ts so a new test-only suffix gets added in both.
Closes #217
The tsconfig exclude pointed at a stale path (
src/server/tools/test-helpers.ts), but the file lives atsrc/core/server/tools/test-helpers.ts. Because the glob never matched,tsccompiled it intodist/. Scoping that out surfaced a second leak:config-branding.compile-test.tsalso shipped, since its-test.tsname is not caught by**/*.test.ts.What changed
Split the build config from the typecheck config.
tsconfig.build.jsonexcludes all test code by pattern (**/*.test.ts,**/*.compile-test.ts,**/test-helpers.ts,**/__tests__/**), so it stays correct if files move. The basetsconfig.jsonstill type-checks the.compile-test.tsbrand guards, which is their whole purpose.buildandbuild:watchnow run-p tsconfig.build.json.Added a regression test that asks tsc which files the build config compiles (
--listFilesOnly) and fails if any test module survives. It also asserts a real source file is present so it cannot pass on an empty program.Verification
dist/.Summary by CodeRabbit
Build Improvements
distbefore compiling.Tests