fix(plan): stop vitest reload flake from lazy zod optimization#15
Merged
Conversation
Vite's initial dep-scan was missing zod (transitively imported via @contextbridge/shared schema files), so it got optimized lazily mid-run. The optimize triggered a page reload that raced with whatever test file vitest was importing next, leaving vitest's exports partially undefined and crashing describe() with "Cannot read properties of undefined (reading 'config')". Pointing optimizeDeps.entries at plan's source forces the scanner to follow imports through @contextbridge/shared up front, so all transitive deps land in the pre-bundle before any test loads. Closes #12
This was referenced May 6, 2026
blimmer
added a commit
that referenced
this pull request
May 8, 2026
🤖 I have created a release *beep* *boop* --- ## [0.3.0](v0.2.0...v0.3.0) (2026-05-08) ### ⚠ BREAKING CHANGES * rename Claude plugin to planbridge@contextbridge; refresh plugins on update ([#52](#52)) ### Features * add automatic release changelog with release-please ([#21](#21)) ([45a1bf1](45a1bf1)) * rename Claude plugin to planbridge@contextbridge; refresh plugins on update ([#52](#52)) ([2794ae6](2794ae6)) * **ui:** add GitHub link to header help menu ([#19](#19)) ([c36289b](c36289b)) ### Bug Fixes * emit plan review analytics from shared runner ([#48](#48)) ([5c769ff](5c769ff)) * **plan:** pre-scan src for transitive deps to stop vitest reload flake ([3b3cc0c](3b3cc0c)), closes [#12](#12) * **plan:** stop vitest reload flake from lazy zod optimization ([#15](#15)) ([3b3cc0c](3b3cc0c)) * refresh Claude marketplace cache during install ([#62](#62)) ([58be09a](58be09a)) * resolve contextbridge via PATH for post-update refresh ([#64](#64)) ([f658af4](f658af4)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: contextbridge-pr-automation[bot] <259134118+contextbridge-pr-automation[bot]@users.noreply.github.com> Co-authored-by: Ben Limmer <ben@benlimmer.com>
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.
Summary
The plan package's vitest browser run was flaky because Vite's initial dep-scan didn't follow imports into workspace package source, so
zod(transitively pulled in via@contextbridge/sharedschema files) was discovered lazily mid-run and triggered a reload that raced with the next test file's import — crashingdescribe()withCannot read properties of undefined (reading 'config'). PointingoptimizeDeps.entriesat plan'ssrc/**/*.{ts,tsx}forces the scanner to crawl through shared up front, so transitive deps land in the pre-bundle before any test loads.Closes #12.
Review focus
optimizeDeps.entriesis the right layer for this. The alternative is declaringzodas a direct devDep on plan; I argued against that since plan never directly imports zod and bun's.bun/isolation correctly enforces "import what you declare." The scan-based fix also stays durable if shared adds another transitive dep later — no per-dep maintenance.src/**/*.{ts,tsx}scans demo/storybook files too. Not harmful (those files only run under storybook, not vitest), but worth a sanity check that no story-only import accidentally pulls a heavy lib into the pre-bundle.Commits
0399e70— fix(plan): pre-scan src for transitive deps to stop vitest reload flake