fix: bundle h3 and cookie-es into the server build#2183
Conversation
If h3 and cookie-es stay external, the SSR build emits bare imports that nitro later re-resolves from the project root, where package managers like yarn may have hoisted the older major versions required by nitropack and unstorage (h3 v1 / cookie-es v1) instead of the versions @solidjs/start needs. Bundling them into entry-server.js removes the bare imports so the wrong copy can never be resolved. Fixes #2101 Fixes #2178 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Deploy Preview for solid-start-landing-page ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
commit: |
birkskyum
left a comment
There was a problem hiding this comment.
Is it the Nitro v2 plugin that pollute with old h3 packages, or where are they imported form?
Yes. The Nitro v2 plugin introduces old H3 transitively: |
Problem
Fixes #2101
Fixes #2178
@solidjs/startdepends on h3 v2 (2.0.1-rc.16), but nitropack and unstorage depend on h3 v1. With yarn (both issue reporters used it), h3 v1 gets hoisted to the project root. Because the SSR build lefth3external, the emitteddist/server/entry-server.jscontained a bareimport { defineHandler, ... } from "h3", and when nitro's rollup bundled that file it resolved"h3"from the project root, hit v1, and failed with:cookie-eshas the same v1/v2 split and is exposed to the same failure.Fix
Add
h3andcookie-estoresolve.noExternalalongside@solidjs/start, so they are bundled intoentry-server.jsduring the Vite SSR build. Since no bareh3/cookie-esimport survives into the intermediate artifact, nitro can never re-resolve them against the wrong hoisted copy, regardless of package manager.Verification
barefixture: Vite client + SSR builds, nitro server build, and prerender all complete without errors.entry-server.js: the only remaining external imports arenode:streamandsolid-js/solid-js/web/solid-js/web/storage— no bareh3orcookie-esimports remain, so the original resolution failure cannot occur.node .output/server/index.mjsserves/with HTTP 200 and SSR-rendered content.🤖 Generated with Claude Code