Skip to content

fix(config): keep the dev toolbar's CSS out of production builds - #2339

Merged
lxsmnsyc merged 1 commit into
mainfrom
fix/devtools-css-in-prod-2327
Oct 13, 2026
Merged

lxsmnsyc merged 1 commit into
mainfrom
fix/devtools-css-in-prod-2327

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

Fixes #2327.

Problem

The dev toolbar's CSS is bundled into the production client output. ErrorBoundary.tsx statically imports DevToolbar:

import { DevToolbar } from "./dev-toolbar/index.tsx";

The toolbar is only used behind import.meta.env.DEV && import.meta.env.START_DEV_OVERLAY, which folds to dead code in production. But dev-toolbar/index.tsx does import "./index.css" as a side effect, and @solidjs/start declared no sideEffects field, so the bundler kept the module for its CSS side effect even though its only binding was unused. The toolbar styles ended up in the client CSS.

Fix

Add "sideEffects": ["**/*.css"] to the package. This tells the bundler that the package's JS modules are side-effect free (so an imported-but-unused module can be dropped) while CSS imports still count as side effects (so CSS a live module imports is kept). With it, the unused toolbar module and its stylesheet are dropped from production, and live CSS is unaffected.

There are a few bare side-effect JS imports in the package (server-only, the server-fn manifest), but they live in modules kept for their exports, so marking JS side-effect free does not drop them.

Impact

Measured on the apps/tests production build:

  • Client entry-client CSS: 17546 bytes to 691 bytes.
  • Dev toolbar tokens (data-start-dev-toolbar, start-dt-*, tc-toolbar) in client CSS: 99 hits to 0.
  • The app's own styles (e.g. body) are still present.

Dev is unaffected: Vite does not tree-shake the dev module graph, and the toolbar branch is live there, so its CSS loads as before.

Testing

  • New build-output regression test apps/tests/src/routes/treeshaking/devtools-css.server.test.ts asserts no client CSS file contains data-start-dev-toolbar. It fails on main and passes with this change.
  • @solidjs/start: 213 unit tests pass, typecheck and validate-imports clean.
  • apps/tests: full Playwright e2e suite passes (42 tests, dev mode, which renders the toolbar), and all 4 treeshaking build-output tests pass.

🤖 Generated with Claude Code

The error boundary statically imports the dev toolbar, whose module imports
its stylesheet as a side effect. The toolbar branch is dead code in
production, but the stylesheet survived tree-shaking because the package
declared no `sideEffects`, so the toolbar styles were bundled into the client
CSS.

Mark only CSS files as having side effects, so the bundler can drop the unused
toolbar module and its stylesheet from production output while keeping the CSS
that live modules import.

Fixes #2327.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4b81529

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

This PR includes changesets to release 1 package
Name Type
@solidjs/start 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

@netlify

netlify Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit 4b81529
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6acd8cf0d2393bddabac6385
😎 Deploy Preview https://deploy-preview-2339--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Oct 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/start@2339

commit: 4b81529

@lxsmnsyc
lxsmnsyc merged commit 45bacdb into main Oct 13, 2026
13 checks passed
@lxsmnsyc
lxsmnsyc deleted the fix/devtools-css-in-prod-2327 branch October 13, 2026 04:52
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.

[Bug?]: devtools css is included in production

2 participants