Skip to content

fix: avoid bundling bare 'h3' import for isolated installs - #294

Merged
kazupon merged 1 commit into
mainfrom
fix/282-bun-h3-import
May 24, 2026
Merged

fix: avoid bundling bare 'h3' import for isolated installs#294
kazupon merged 1 commit into
mainfrom
fix/282-bun-h3-import

Conversation

@kazupon

@kazupon kazupon commented May 24, 2026

Copy link
Copy Markdown
Member

Description

Linked Issues

resolve #282

Additional context

Summary by CodeRabbit

  • Chores
    • Updated build script configuration
    • Added peer dependency version constraints for h3 (>=2.0.0-0 <3.0.0) and nitro (>=3.0.0-0 <4.0.0) packages to ensure proper installation compatibility

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4cf269a1-c39f-47af-b438-fd05a8313093

📥 Commits

Reviewing files that changed from the base of the PR and between c5e8256 and b81a1ce.

📒 Files selected for processing (6)
  • package.json
  • packages/h3/package.json
  • packages/h3/src/index.ts
  • packages/nitro/package.json
  • packages/nitro/src/index.ts
  • packages/shared/src/context.ts

📝 Walkthrough

Walkthrough

This PR refactors shared locale and context helpers into factory functions that accept getEventContext as a parameter, allowing h3 and nitro adapters to instantiate them locally. This eliminates transitive dependencies and resolves module resolution issues in non-hoisted package managers (bun, pnpm) where packages can only access explicitly declared dependencies.

Changes

Factory-based dependency isolation

Layer / File(s) Summary
Shared factory abstraction
packages/shared/src/context.ts
getLocaleAndEventContext and getDetectorLocale are replaced with createGetLocaleAndEventContext and createGetDetectorLocale factory functions that accept a GetEventContext parameter and return async handlers. Module augmentation for h3 is removed in favor of consumer-side augmentation.
H3 adapter factory instantiation
packages/h3/src/index.ts, packages/h3/package.json
H3 package imports factory functions and instantiates them locally using h3's getEventContext, exporting the results as local constants. Adds h3 peer dependency declaring >=2.0.0-0 <3.0.0.
Nitro adapter factory instantiation
packages/nitro/src/index.ts, packages/nitro/package.json
Nitro package imports factory functions and instantiates them locally using nitro's getEventContext, exporting the results as local constants. Adds nitro peer dependency declaring >=3.0.0-0 <4.0.0.
Build script configuration
package.json
Removes --color flag from root fix script runner.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • intlify/srvmid#43: Introduces getDetectorLocale API in h3/hono packages; this PR refactors the underlying implementation to factory-based instantiation and updates exports accordingly.

Poem

🐰 A rabbit's refactoring rhyme,
Factories now, no transitive climb!
H3 and Nitro, pass their own key,
No hoisting troubles—just dependency free! 🌿✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes an unrelated change: removing the --color flag from the root package.json fix script, which is outside the scope of resolving the isolated install issue. Remove the --color flag change from package.json as it is unrelated to the isolated install issue. Keep only the factory function refactoring and peerDependencies changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: avoiding bundling bare 'h3' imports to support isolated installs, which aligns with the primary objective from issue #282.
Linked Issues check ✅ Passed The PR addresses issue #282 by implementing factory functions and adding peerDependencies to avoid bare 'h3' imports, instead relying on consumer-side instantiation for isolated installs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/282-bun-h3-import

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kazupon kazupon added bug Includes new features H3 Nitro labels May 24, 2026
@kazupon kazupon changed the title fix(nitro): avoid bundling bare 'h3' import for isolated installs fix: avoid bundling bare 'h3' import for isolated installs May 24, 2026
@pkg-pr-new

pkg-pr-new Bot commented May 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@intlify/elysia@294
npm i https://pkg.pr.new/@intlify/h3@294
npm i https://pkg.pr.new/@intlify/hono@294
npm i https://pkg.pr.new/@intlify/nitro@294

commit: b81a1ce

@kazupon
kazupon merged commit 6423bca into main May 24, 2026
10 checks passed
@kazupon
kazupon deleted the fix/282-bun-h3-import branch May 24, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Includes new features H3 Nitro

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nitro with pnpm/bun: The requested module 'h3' does not provide an export named 'getEventContext'

1 participant