chore: fail fast on dev builds, stop running shared tests twice - #264
Merged
Merged
Conversation
- apps/web: `pnpm build` now aborts with a clear message when NODE_ENV is set to anything other than production. A sourced local .env (NODE_ENV= development) otherwise breaks the prerender of /_global-error with a React useContext error that points in the wrong direction. CI and the deploy never set NODE_ENV, so they are unaffected. - packages/shared: vitest only collects src/**/*.test.ts. `tsc` emits the test files into dist/, which vitest collected as well, so CI ran every shared suite twice and local counts depended on whether dist existed.
db, ui, i18n and realtime also compile with tsc into dist/ and have no vitest config. They have no tests today, so nothing runs twice yet, but the first test added to any of them would also run from its compiled copy, the same way packages/shared did. bot and web don't emit (noEmit / next build).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small fixes for things that cost time before.
Build guard for NODE_ENV (apps/web)
pnpm buildnow runsscripts/assert-build-env.mjsfirst. IfNODE_ENVis set to anything other thanproduction, it stops with a short explanation and the right command.Background (2026-09-01): the local
.envsetsNODE_ENV=developmentforpnpm dev. Sourcing it to getDATABASE_URLmade the production build load React's development bundle, and the prerender of/_global-errorfailed withCannot read properties of null (reading 'useContext'). That message looks like a duplicate React or a Windows problem, and it took two wrong guesses to find the real cause. CI and the deploy never setNODE_ENV, so neither is affected.Checked: exits 1 with
NODE_ENV=development, 0 when unset and 0 withproduction.Tests ran twice from dist
packages/sharedbuilds with plaintsc, its tsconfig includes the test files, sodist/*.test.jsgets emitted.testdepends on^buildin turbo, and vitest no longer excludesdistby default, so CI collected every shared suite twice and local counts changed depending on whetherdistexisted.packages/shared/vitest.config.tslimits collection tosrc/**/*.test.ts.src/**/*.test.ts,.tsxfor ui) is added to the other packages that emit intodist/:packages/db,packages/ui,packages/i18n,apps/realtime. None of them has tests yet, so nothing runs twice there today, but the first test added would.apps/bot(tsc --noEmit) andapps/web(next build,noEmit) don't emit and are not affected.I left the test files in the
tscbuild.dist/is not consumed by anything (all packages export their sources), and excluding them would need a separate build tsconfig sotypecheckkeeps covering the tests.Verification
rm -rf distalone is not enough to reproduce this locally.tsconfig.base.jsonsetsincremental: trueand thetsconfig.tsbuildinfosits next todist/, not in it, so after deleting onlydist/atscbuild considers itself up to date and emits nothing. The checks below therefore delete both.With the compiled test files present,
vitest run --reporter=verboselists onlysrc/*.test.tsfiles. After a clean build of db, ui, i18n and realtime, none of them has*.test.jsindistand each reports "No test files found" as before. bot still runs its 3 files.(The counts are from this branch, which predates
form-definition.test.tsfrom #261. With that merged it is 11 files.)