Skip to content

fix: keep a semi-framework package's dependencies out of optimizeDeps.include - #376

Merged
ryansolid merged 1 commit into
nextfrom
fix/semi-framework-deps-optimize
Sep 27, 2026
Merged

ryansolid merged 1 commit into
nextfrom
fix/semi-framework-deps-optimize

Conversation

@ryansolid

Copy link
Copy Markdown
Member

Fixes #375.

Problem

Since the semi-framework classification landed in next.44 (ssr-inline-solid-consumers), any package with solid-js / @solidjs/web in dependencies or peerDependencies is ssr.noExternal under vite dev so it shares the app's runtime copy. Right call for the package itself — but vitefu's crawlFrameworkPkgs treats a semi-framework package like a framework package for its dependencies too: every CJS dependency is deep-included as "pkg > dep" in the browser's optimizeDeps.include.

For a library that ships its build-time half in the same package that means node-only modules in the client pre-bundle. @yak/solid lists @swc/core (its Vite plugin needs it), and rolldown fails on the native .node binding before the dev server serves anything:

[UNLOADABLE_DEPENDENCY] Could not load …/@swc/core-darwin-arm64/swc.darwin-arm64.node
 159 │         return require('@swc/core-darwin-arm64')
     │                        ╰── stream did not contain valid UTF-8

Before next.44 such a package was "unknown" to the crawl: read, found to be neither kind, and not recursed into — its dependencies were never touched.

Fix

Sharing the runtime needs nothing pre-bundled. isSemiFrameworkPkgByJson records the names it classifies, and after the crawl every optimizeDeps.include chain that passes through one of them is dropped. A browser-side CJS dependency of such a package is then discovered and optimized by Vite on first use — the behaviour it had before the package was classified at all. Framework packages (a solid export condition) keep vitefu's full treatment; that contract is unchanged.

vitefu offers no "noExternal without crawling deps" option (isSemiFrameworkPkgByJson always recurses), so the post-filter is the smallest change.

Verification

  • next-yak's e2e/bundlers/vite-solid (client + SSR dev server, plugins: [yak(), solid({ ssr: true })]) on solid-js 2.0.0-rc.10: fails in dependency optimization with next.44 and with next at 08782f2; with this branch built and installed via tarball, 36 cases + 7 HMR cases pass in both fold modes.
  • examples/ssr: build and pnpm test (8/8 boundary assertions) pass.
  • pnpm build clean.

Context: DigitecGalaxus/next-yak#659 pins @solidjs/vite-plugin at next.38 because of this; once this ships they can take next.45+ (which also carries the componentNames → sourceNames rename the rc.10 compiler requires).

Co-authored with Claude via Cursor.

….include (#375)

Since the semi-framework classification (any package with solid-js or
@solidjs/web in dependencies/peerDependencies is ssr.noExternal so it
shares the app's runtime copy), vitefu's crawl also deep-included every
CJS dependency of such a package into the browser's optimizeDeps.include,
as it does for framework packages. For @yak/solid that is @swc/core, and
rolldown failed on its native .node binding before vite dev served a page.

Sharing the runtime needs nothing pre-bundled. Record the names
isSemiFrameworkPkgByJson classifies and drop every include chain that
passes through one; a browser-side CJS dependency of such a package is
discovered and optimized on first use, as before the package was
classified. Framework packages (a solid export condition) keep vitefu's
full treatment.

Verified against next-yak's vite-solid e2e (client + SSR dev server,
36 cases + 7 HMR cases, both fold modes) on solid-js 2.0.0-rc.10, which
fails in dependency optimization on next.44/next.45 and passes with this.

Co-authored-by: Claude <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 94f1878

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 Sep 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 94f1878

@ryansolid
ryansolid merged commit 9fcce5c into next Sep 27, 2026
6 checks passed
@ryansolid
ryansolid deleted the fix/semi-framework-deps-optimize branch September 27, 2026 09:38
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