Skip to content

fix: honor the host's noExternal patterns when adding vitefu's SSR externals - #360

Merged
ryansolid merged 1 commit into
solidjs:nextfrom
brenelz:fix/honor-host-noexternal-patterns
Sep 11, 2026
Merged

fix: honor the host's noExternal patterns when adding vitefu's SSR externals#360
ryansolid merged 1 commit into
solidjs:nextfrom
brenelz:fix/honor-host-noexternal-patterns

Conversation

@brenelz

@brenelz brenelz commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Problem

configEnvironment for the ssr environment appends vitefu's ssr.external to resolve.external, filtering out anything the merged noExternal list inlines — but with a literal noExternal.includes(dep) check. Vite judges noExternal differently: string entries are picomatch patterns and RegExp entries are tests (createFilter(undefined, noExternal, { resolve: false }) in createIsConfiguredAsExternal), and external takes precedence over noExternal.

Since 3.0.0-next.41 the crawl also classifies packages that consume the Solid runtime as semi-framework, so their non-Solid dependencies now land in ssr.external. A host that inlines its packages by pattern gets them externalized anyway. Concretely, TanStack Start sets resolve.noExternal: ['@tanstack/start**', '@tanstack/solid-start**']; @tanstack/solid-start depends on solid-js, so @tanstack/start-server-core, start-client-core, start-plugin-core and start-storage-context were added to external. Those packages import #tanstack-router-entry and friends, which only Vite's plugin pipeline can resolve, so every vite dev SSR request failed:

TypeError [ERR_PACKAGE_IMPORT_NOT_DEFINED]: Package import specifier "#tanstack-router-entry" is not defined in package …/@tanstack/start-server-core/package.json

Resolved environments.ssr.resolve.external for a TanStack Start Solid app on next.42:

["@babel/core","@jridgewell/remapping","@nothing-but/utils","@solidjs/babel-plugin","@solidjs/compiler","@tanstack/history","@tanstack/router-core","@tanstack/start-client-core","@tanstack/start-plugin-core","@tanstack/start-server-core","@tanstack/start-storage-context","isbot","pathe","seroval","seroval-plugins"]

Fix

Filter vitefu's externals with the same matcher Vite uses for noExternal (createFilter(undefined, noExternal, { resolve: false })), so pattern and RegExp entries are honored. While there, a single string or RegExp noExternal value is normalized into the merged list instead of being dropped.

Same app with this patch (TanStack's own workaround plugin removed):

["@babel/core","@jridgewell/remapping","@nothing-but/utils","@solidjs/babel-plugin","@solidjs/compiler","@tanstack/history","@tanstack/router-core","isbot","pathe","seroval","seroval-plugins"]

vite dev SSR answers 200 again. Context: TanStack/router#8348 (the rc.7 / next.42 bump), which carries a host-side guard until this lands.

🤖 Generated with Claude Code

…ternals

The ssr environment hook already refuses to re-externalize anything
`noExternal` inlines, but it compared literal names, while Vite treats
string entries as picomatch patterns and RegExp entries as tests
(`createFilter(undefined, noExternal, { resolve: false })`). Since
next.41 the crawl also reaches packages that consume the Solid runtime
and hands their non-Solid dependencies to `ssr.external`, so a host that
inlines by pattern (TanStack Start's `@tanstack/start**`) saw those
packages externalized and `vite dev` failed with
ERR_PACKAGE_IMPORT_NOT_DEFINED for the `#tanstack-*` imports only Vite
can resolve. Filter the externals with the same matcher Vite uses, and
keep a single string/RegExp `noExternal` instead of dropping it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4fb1af3

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 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 4fb1af3

@ryansolid
ryansolid merged commit e14c283 into solidjs:next Sep 11, 2026
6 checks passed
brenelz added a commit to TanStack/router that referenced this pull request Sep 11, 2026
…0.0-next.43

Moves solid-js/@solidjs/web to ^2.0.0-rc.8, @solidjs/vite-plugin to
^3.0.0-next.43 and the webpack example's @solidjs/babel-plugin to
^2.0.0-rc.8. rc.8 is ESM-only with engines.node >= 22.12.

rc.8 ships the upstream fix for the buffered server-function request
(a71e42e), so the srvx Request normalization from the rc.7 commit is
dropped again. @solidjs/vite-plugin next.43 honors the host's
resolve.noExternal patterns when externalizing the dependencies of
Solid consumers (solidjs/solid-vite-plugin#360), which is what broke
`vite dev` with "Package import specifier '#tanstack-router-entry' is
not defined" on next.41/42.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
birkskyum pushed a commit to TanStack/router that referenced this pull request Sep 11, 2026
…0.0-next.43 (#8348)

* chore(solid): bump to solid-js 2.0.0-rc.7 and @solidjs/vite-plugin 3.0.0-next.42

Moves solid-js/@solidjs/web to ^2.0.0-rc.7, @solidjs/vite-plugin to
^3.0.0-next.42, @rsbuild/plugin-solid to ^2.0.0-rc.0 and the webpack
example's @solidjs/babel-plugin to ^2.0.0-rc.7 across the monorepo.

@tanstack/solid-start now normalizes Request subclasses (srvx's Node
adapter) into native Requests before Solid's server-function handler
sees them: rc.7 buffers every POST body via `new Request(request, {
body })`, which undici only accepts for its own instances, so every
POST answered 400 under srvx.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore(solid): bump to solid-js 2.0.0-rc.8 and @solidjs/vite-plugin 3.0.0-next.43

Moves solid-js/@solidjs/web to ^2.0.0-rc.8, @solidjs/vite-plugin to
^3.0.0-next.43 and the webpack example's @solidjs/babel-plugin to
^2.0.0-rc.8. rc.8 is ESM-only with engines.node >= 22.12.

rc.8 ships the upstream fix for the buffered server-function request
(a71e42e), so the srvx Request normalization from the rc.7 commit is
dropped again. @solidjs/vite-plugin next.43 honors the host's
resolve.noExternal patterns when externalizing the dependencies of
Solid consumers (solidjs/solid-vite-plugin#360), which is what broke
`vite dev` with "Package import specifier '#tanstack-router-entry' is
not defined" on next.41/42.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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