fix(core): split client/server tsdown builds to keep ws/node out of browser#347
Merged
Conversation
…of the browser bundle Rolldown's automatic chunking was hoisting the `__exportAll` runtime helper into a chunk that also reached `devframe/rpc/transports/ws-server`, so client `DockStandalone-*.js` statically imported `ws` and threw `SyntaxError: ... does not provide an export named 'WebSocketServer'` in the browser. Split `packages/core/tsdown.config.ts` into two configs (client + server) so the chunk graphs are independent, and add a `build:check` guard that BFS-walks `dist/client/*.js` and fails on any forbidden static import (`ws`, `h3`, `node:*`, `devframe/rpc/transports/*`, `devframe/node*`).
commit: |
Move the forbidden-import check out of the `build:check` npm script and into the client config's `build:done` hook, so it runs automatically as part of the tsdown build (including `watch` mode) without needing a separate pipeline step. The script becomes an exported `checkClientDist` function that throws on violation; `package.json` drops the `build:check` entry.
This was referenced May 15, 2026
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.
Description
In
0.1.23, the browser-side dock crashes withSyntaxError: ... does not provide an export named 'WebSocketServer': rolldown's automatic chunking hoisted the__exportAllruntime helper into a chunk that also reacheddevframe/rpc/transports/ws-server, so the clientDockStandalone-*.jsstatically pulled inws(which Vite resolves tows/browser.js, a module that has noWebSocketServerexport). Splitpackages/core/tsdown.config.tsinto two configs (client + server) inside onedefineConfig([...])so the chunk graphs are independent — server modules structurally cannot leak into the client output. Also added abuild:checkscript (packages/core/scripts/check-client-dist.ts) that BFS-walks every chunk reachable fromdist/client/inject.jsanddist/client/webcomponents.js(following both static and dynamic imports) and fails the build on any forbidden static import (ws,h3,node:*,devframe/rpc/transports/*,devframe/node*), wired into the existingbuildstep so it gatesprepack.Linked Issues
Additional context
Verified via full
pnpm build(turbo, 5 packages), the new guard (scans 8 chunks, all clean), manual greps ondist/client/(nows/h3/node:/ws-servermatches), andpnpm test/pnpm typecheck/pnpm lint— all green. Theexport *cleanup inwebcomponents/index.tsis intentionally deferred since it's no longer load-bearing now that the builds are isolated.