Skip to content

fix: pre-bundle @solidjs/signals when the app depends on it directly - #458

Open
ryansolid wants to merge 1 commit into
nextfrom
claude/project-thread-5q01in
Open

ryansolid wants to merge 1 commit into
nextfrom
claude/project-thread-5q01in

Conversation

@ryansolid

Copy link
Copy Markdown
Member

Requested by Ryan · project thread

Problem

OpenClaw's Solid 2 migration hit this in Vitest browser mode: Vite re-optimized @solidjs/signals mid-run and reloaded the page, which showed up as 14 WebKit "import failures". Their workaround was adding @solidjs/signals to optimizeDeps.include by hand.

The first optimizer pass reaches signals only through solid-js, so it bundles signals inside the solid-js pre-bundle. When a module the scanner never reached (a browser-mode test file, a non-literal dynamic import) then imports @solidjs/signals by name, Vite treats it as a newly discovered dep, re-optimizes, and does a full reload.

Fix

Under serve, add @solidjs/signals to optimizeDeps.include when it resolves from the project root. That is the same findPackageDir gate resolve.dedupe already uses for it. If signals doesn't resolve from the root (pnpm's isolated layout with only a transitive dependency), the app can't import it by name anyway, and an unresolvable include entry would warn on every start. So that case is unchanged.

Verified

I tested a plain Vite 8 app: main.tsx uses solid-js and later runs import(/* @vite-ignore */ '/late.ts'), and late.ts imports @solidjs/signals. I drove it with Playwright.

  • Before: dependency optimized: @solidjs/signals → optimized dependencies changed. reloading, and 2 navigations.
  • After: no re-optimize and 1 navigation. solid-js.js imports from the @solidjs_signals.js pre-bundle, so there is still one engine.
  • With signals only transitive (pnpm, not a direct dependency): no include entry, no warning, and no reload.

There's a patch changeset.


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016PFhdmTPKsQSS3fENqTi5b
@ryansolid ryansolid self-assigned this Oct 21, 2026
@changeset-bot

changeset-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 60f3a1f

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

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

@pkg-pr-new

pkg-pr-new Bot commented Oct 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/vite-plugin@458

commit: 60f3a1f

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.

2 participants