Skip to content

fix: bundle h3 and cookie-es into the server build - #2183

Merged
brenelz merged 3 commits into
mainfrom
fix/bundle-h3-cookie-es
Jul 16, 2026
Merged

fix: bundle h3 and cookie-es into the server build#2183
brenelz merged 3 commits into
mainfrom
fix/bundle-h3-cookie-es

Conversation

@brenelz

@brenelz brenelz commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Problem

Fixes #2101
Fixes #2178

@solidjs/start depends 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 left h3 external, the emitted dist/server/entry-server.js contained a bare import { defineHandler, ... } from "h3", and when nitro's rollup bundled that file it resolved "h3" from the project root, hit v1, and failed with:

RollupError: entry-server.js: "defineHandler" is not exported by "node_modules/h3/dist/index.mjs"

cookie-es has the same v1/v2 split and is exposed to the same failure.

Fix

Add h3 and cookie-es to resolve.noExternal alongside @solidjs/start, so they are bundled into entry-server.js during the Vite SSR build. Since no bare h3/cookie-es import survives into the intermediate artifact, nitro can never re-resolve them against the wrong hoisted copy, regardless of package manager.

Verification

  • Built the bare fixture: Vite client + SSR builds, nitro server build, and prerender all complete without errors.
  • Inspected the built entry-server.js: the only remaining external imports are node:stream and solid-js/solid-js/web/solid-js/web/storage — no bare h3 or cookie-es imports remain, so the original resolution failure cannot occur.
  • Smoke-tested the production output: node .output/server/index.mjs serves / with HTTP 200 and SSR-rendered content.

🤖 Generated with Claude Code

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>
@netlify

netlify Bot commented Jul 15, 2026

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 26944d2
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6a58d950dd59bb0008ddb541
😎 Deploy Preview https://deploy-preview-2183--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.

@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 26944d2

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/solidjs/solid-start/@solidjs/start@2183
npm i https://pkg.pr.new/solidjs/solid-start/@solidjs/vite-plugin-nitro-2@2183

commit: 26944d2

Comment thread packages/start/src/config/index.ts

@birkskyum birkskyum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the Nitro v2 plugin that pollute with old h3 packages, or where are they imported form?

@brenelz

brenelz commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

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:
@solidjs/vite-plugin-nitro-2
└─ nitropack@2.13.1
├─ h3@1.15.6
├─ listhen → h3@1.15.6
└─ unstorage@1.17.4 → h3@1.15.6
h3@1.15.6 then introduces cookie-es@1.2.2. Nitro itself also directly uses cookie-es@2.

@birkskyum

Copy link
Copy Markdown
Member

Changeset missing

@brenelz
brenelz merged commit 12dc2d3 into main Jul 16, 2026
10 checks passed
@brenelz
brenelz deleted the fix/bundle-h3-cookie-es branch July 16, 2026 13:17
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?]: [v2] build when using yarn fails importing from h3 [Bug?]: npm init solid@latest generates a template that is unbuildable

2 participants