{{ message }}
Repository navigation
fix(devtools-vite): inject the bus port into pre-bundled dependency chunks - #538
Open
AlemTuzlak wants to merge 1 commit into
Open
AlemTuzlak wants to merge 1 commit into
AlemTuzlak wants to merge 1 commit into
Conversation
…hunks Vite pre-bundles npm installs of @tanstack/react-devtools into chunks under node_modules/.vite/deps. Their ids do not contain "@tanstack/devtools", so connection-injection skipped them and __TANSTACK_DEVTOOLS_PORT__ stayed in the code. The browser then always dialed 4206, also when the server bus moved to another port. The examples link packages with workspace:*, and Vite does not pre-bundle linked packages, so the examples did not show the bug. Fixes #536
|
View your CI Pipeline Execution ↗ for commit a2b0718
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit a2b0718
☁️ Nx Cloud last updated this comment at |
3 of 5 tasks
This branch has not been deployed
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.

When Vite pre-bundles
@tanstack/react-devtoolsfrom npm, the browser event bus client always connects to port 4206. The server bus can use another port (eventBusConfig.port, or a random port afterEADDRINUSE), so the client cannot connect. This PR also injects the port, host, and protocol into Vite's pre-bundled chunks undernode_modules/.vite/deps*.🎯 Changes
connection-injectionskipped pre-bundled chunks: their ids (for example/node_modules/.vite/deps/BRS44MK7-KeTQTbh5.js) do not contain@tanstack/devtools. As a result,__TANSTACK_DEVTOOLS_PORT__stayed in the code andgetDefaultPortreturned 4206./.vite/deps. The placeholder check still limits the transform to modules that contain the placeholders. Other packages stay untouched.workspace:*, and Vite does not pre-bundle linked packages.✅ Checklist
pnpm test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Testing
Commands run
vitest runinpackages/devtools-vite: 22 tests pass, with a new test for a.vite/depsid.eslintandtscinpackages/devtools-vite: pass.pnpm test:pr.Manual test
@tanstack/react-devtoolsfrom npm, and setdevtools({ eventBusConfig: { port: 4260 } }).WebSocket connection error, and the served.vite/depschunk still contains__TANSTACK_DEVTOOLS_PORT__.New WebSocket client connected, and the chunk contains4260.How this PR makes testing easy
A unit test in
packages/devtools-vite/tests/index.test.tstransforms a.vite/depsid and expects the port.Linked issues
Fixes #536
Risk / rollback
Low. Only modules that contain the devtools placeholders change. To undo, revert this PR.
🤖 Generated with Claude Code
Summary by CodeRabbit