Skip to content

fix(devtools): prevent solid-js from leaking into server bundles#367

Merged
AlemTuzlak merged 16 commits intomainfrom
worktree-zany-yawning-quill
Mar 6, 2026
Merged

fix(devtools): prevent solid-js from leaking into server bundles#367
AlemTuzlak merged 16 commits intomainfrom
worktree-zany-yawning-quill

Conversation

@AlemTuzlak
Copy link
Collaborator

Summary

  • Moved all solid-js runtime imports (render, Portal, lazy, ClientEventBus) from core.tsx into a new mount-impl.tsx file
  • core.ts now uses import('./mount-impl') inside mount() so solid-js is never in the static import graph
  • Server/client entry points (server.js, index.js, dev.js) are now completely free of solid-js references — solid code only loads as a separate chunk when mount() is called on the client

Problem

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

  • All 77 nx tasks pass (test:lib, test:types, test:eslint, test:knip, test:sherif, test:build, build)
  • dist/server.js and dist/index.js contain zero solid-js references
  • examples/react/bundling-repro builds successfully with zero solid-js in the server bundle

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-bot
Copy link

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: 6a087c4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@tanstack/devtools-utils Patch
@tanstack/devtools Patch
@tanstack/preact-devtools Patch
@tanstack/react-devtools Patch
@tanstack/solid-devtools Patch
@tanstack/vue-devtools Patch

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

@nx-cloud
Copy link

nx-cloud bot commented Mar 4, 2026

View your CI Pipeline Execution ↗ for commit 6a087c4

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 2m 6s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-06 12:24:52 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 4, 2026

More templates

@tanstack/devtools

npm i https://pkg.pr.new/@tanstack/devtools@367

@tanstack/devtools-client

npm i https://pkg.pr.new/@tanstack/devtools-client@367

@tanstack/devtools-ui

npm i https://pkg.pr.new/@tanstack/devtools-ui@367

@tanstack/devtools-utils

npm i https://pkg.pr.new/@tanstack/devtools-utils@367

@tanstack/devtools-vite

npm i https://pkg.pr.new/@tanstack/devtools-vite@367

@tanstack/devtools-event-bus

npm i https://pkg.pr.new/@tanstack/devtools-event-bus@367

@tanstack/devtools-event-client

npm i https://pkg.pr.new/@tanstack/devtools-event-client@367

@tanstack/preact-devtools

npm i https://pkg.pr.new/@tanstack/preact-devtools@367

@tanstack/react-devtools

npm i https://pkg.pr.new/@tanstack/react-devtools@367

@tanstack/solid-devtools

npm i https://pkg.pr.new/@tanstack/solid-devtools@367

@tanstack/vue-devtools

npm i https://pkg.pr.new/@tanstack/vue-devtools@367

commit: f3f2374

AlemTuzlak and others added 15 commits March 5, 2026 11:48
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.
@AlemTuzlak AlemTuzlak merged commit 024ea7d into main Mar 6, 2026
4 checks passed
@AlemTuzlak AlemTuzlak deleted the worktree-zany-yawning-quill branch March 6, 2026 12:24
@github-actions github-actions bot mentioned this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant