fix(devtools): prevent solid-js from leaking into server bundles#367
Merged
AlemTuzlak merged 16 commits intomainfrom Mar 6, 2026
Merged
fix(devtools): prevent solid-js from leaking into server bundles#367AlemTuzlak merged 16 commits intomainfrom
AlemTuzlak merged 16 commits intomainfrom
Conversation
Move all solid-js runtime imports (render, Portal, lazy, ClientEventBus) from core into a new mount-impl.tsx file loaded via dynamic import(). This ensures solid-js code is never in the static import graph and only loads as a separate chunk when mount() is called on the client.
🦋 Changeset detectedLatest commit: 6a087c4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
View your CI Pipeline Execution ↗ for commit 6a087c4
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/devtools
@tanstack/devtools-client
@tanstack/devtools-ui
@tanstack/devtools-utils
@tanstack/devtools-vite
@tanstack/devtools-event-bus
@tanstack/devtools-event-client
@tanstack/preact-devtools
@tanstack/react-devtools
@tanstack/solid-devtools
@tanstack/vue-devtools
commit: |
Add ambient module declaration (barrel-types.d.ts) so TypeScript can resolve @tanstack/devtools-utils/solid on clean checkouts without dist/.
…pre-bundling esbuild follows dynamic imports with string literals during Vite's dependency optimization, pulling solid-js into the SSR bundle. Using a variable path prevents static analysis from following the import.
…dflare SSR The ./solid export was missing a workerd condition, causing Vite's SSR dep optimizer (esbuild) to resolve to the client entry instead of server.js when running under Cloudflare workerd. The client entry's compiled Solid JSX imports use/setStyleProperty from solid-js/web which don't exist in the server entry, crashing the dev server. Also reverts the variable import workaround in class.ts back to a literal import, since the workerd condition now properly routes SSR resolution to the server entry.
Replace the cross-package bare specifier import('@tanstack/devtools-utils/solid')
with a relative import('./class-mount-impl'). Bare specifiers in dynamic imports
inside pre-bundled dependencies aren't resolved by bundlers like esbuild/webpack,
causing "Failed to resolve module specifier" errors in the browser.
The relative import works in all bundlers (Vite, Next.js, etc.) because the
class-mount-impl.js file is co-located in the same dist directory, built
together via a single vite config with vite-plugin-solid for JSX compilation.
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
render,Portal,lazy,ClientEventBus) fromcore.tsxinto a newmount-impl.tsxfilecore.tsnow usesimport('./mount-impl')insidemount()so solid-js is never in the static import graphserver.js,index.js,dev.js) are now completely free of solid-js references — solid code only loads as a separate chunk whenmount()is called on the clientProblem
When using
@tanstack/react-devtools(or any non-Solid adapter) in SSR environments like Cloudflare workerd, solid-js code leaked into the server bundle through the static import graph of@tanstack/devtools, causing runtime crashes.Test Plan
dist/server.jsanddist/index.jscontain zero solid-js referencesexamples/react/bundling-reprobuilds successfully with zero solid-js in the server bundle