-
-
Notifications
You must be signed in to change notification settings - Fork 1
Updated h3 to v2 #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated h3 to v2 #31
Conversation
WalkthroughA devDependency version bump of h3 in packages/h3/package.json from ^1.15.4 to ^2.0.1-rc.5. No functional code changes or structural modifications are present. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related issues
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "@types/node": "catalog:", | ||
| "@types/supertest": "^6.0.3", | ||
| "h3": "^1.15.4", | ||
| "h3": "^2.0.1-rc.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Upgrading to h3 ^2.0.1-rc.5 introduces risk due to several factors:
- Release candidate status: RC versions are pre-release and may have breaking changes before the stable v2 release, potentially causing unexpected breakage in dependent code.
- Major version bump: The upgrade from h3 v1 to v2 typically includes significant API changes. Without comprehensive test evidence, compatibility is uncertain.
- Insufficient verification evidence: The PR description states the code "appears to work," but this lacks concrete evidence (test results, CI logs, API compatibility audit).
Before merging, confirm:
- All tests pass with h3 v2.0.1-rc.5
- No breaking API changes affect the code in this package
- CI/CD pipeline succeeds with the new version
- Consider whether to wait for the stable v2 release
Run the following to verify h3 v2 compatibility and test status:
Additionally, search the web for breaking changes between h3 v1 and v2:
🏁 Script executed:
#!/bin/bash
# Description: Verify h3 v2 API compatibility and test status
# 1. Check h3 v2 changelog/breaking changes
echo "=== Checking h3 v2 release notes ==="
curl -s https://github.com/unjs/h3/releases/tag/v2.0.1-rc.5 | grep -A 20 "Breaking" || echo "No breaking changes section found"
# 2. Search for h3 API usage in source code
echo -e "\n=== Searching for h3 API usage in source code ==="
rg -nP --type=ts --type=js 'from\s+["\']h3["\']|import.*from.*h3' --no-heading
# 3. Look for any migration notes or comments
echo -e "\n=== Checking for migration-related comments ==="
rg -nP '(TODO|FIXME|XXX|HACK).*h3|h3.*v2|migration' --type=ts --type=jsLength of output: 191
🌐 Web query:
h3 v2 breaking changes from v1
💡 Result:
Here are the main breaking changes when moving H3 v1 → v2 (summary — see migration guide for full details):
- ESM-only / Node requirement: v2 targets modern runtimes (ESM-first) and requires Node >= 20.11 (or Bun/Deno). CommonJS usage is more limited. [1]
- Web-standards rewrite: APIs are built on web primitives (Request, Response, URL, Headers). [1]
- Router integration: the router is now part of the H3 core (use new H3() instead of createApp/createRouter). [1]
- New route engine: route matching moved to the rou3 engine — matching rules/behavior changed (some patterns behave slightly differently). [1]
- Middleware path matching change: app.use("/path", handler) now matches exactly "/path" (not subpaths); use "/path/**" to match subpaths like before. [1]
- event.path semantics: handlers now receive the full path (prefixes are not stripped); use withBase(base, handler) when needed. [1]
- Handler lifecycle/returns: any handler can return a Response; middleware may opt not to return — H3 will try subsequent handlers and produce a 404/empty 200 depending on flow. [1][2]
- Runtime/adapter changes and docs move: project moved to new org/domain (h3.dev) and docs/guide were rewritten — adjust imports and consult new docs. [2]
Sources: H3 migration guide and v2 beta announcement. [1][2]
References
[1] H3 migration guide (v1→v2). h3.dev/migration.
[2] H3 v2 beta announcement / blog. h3.dev/blog/v2-beta.
I need to search the codebase properly to understand actual h3 API usage and verify test status.
I need to examine the codebase to verify whether h3 APIs are actually used and whether tests pass with the RC version.
🏁 Script executed:
#!/bin/bash
# Search for actual h3 imports and usage in source code
echo "=== Finding h3 imports in TypeScript/JavaScript files ==="
fd -e ts -e js -e mts -e mjs | head -20 && echo "..." || true
echo -e "\n=== Searching for 'from h3' or 'import.*h3' ==="
rg 'from\s+["\']h3["\']|import\s+.*\s+from\s+["\']h3["\']' -A 2
echo -e "\n=== Checking for direct h3 API usage patterns ==="
rg 'createApp|defineEventHandler|useQuery|readBody|setHeader' --type ts --type js -c | head -10
echo -e "\n=== Looking for test files ==="
fd -e test.ts -e test.js -e spec.ts -e spec.js
echo -e "\n=== Checking package.json scripts ==="
cat packages/h3/package.json | grep -A 5 '"scripts"'Length of output: 945
🏁 Script executed:
#!/bin/bash
# Search for actual h3 imports and usage in source code
echo "=== Searching for h3 imports ==="
rg 'from.*["\']h3["\']|import.*h3' --type ts --type js -A 1
echo -e "\n=== Checking test directory structure ==="
fd -t d test spec __tests__ 2>/dev/null | head -5
echo -e "\n=== Looking for test files in packages/h3 ==="
fd -e test.ts -e test.js -e spec.ts -e spec.js packages/h3
echo -e "\n=== Checking packages/h3 structure ==="
ls -la packages/h3/src/ 2>/dev/null | head -20 || echo "src directory not found"
echo -e "\n=== Reading packages/h3/package.json scripts section ==="
jq '.scripts' packages/h3/package.json 2>/dev/null || cat packages/h3/package.json | grep -A 10 '"scripts"'Length of output: 102
🏁 Script executed:
#!/bin/bash
# Simplified approach to find h3 usage and test status
echo "=== Checking packages/h3 source file content ==="
cat packages/h3/src/index.ts | head -40
echo -e "\n=== Looking for h3 package references ==="
grep -r "h3" packages/h3/src --include="*.ts" --include="*.js" | head -10
echo -e "\n=== Package.json test script ==="
cat packages/h3/package.json | grep -E 'test|scripts' -A 20 | head -30
echo -e "\n=== Check if test files exist ==="
ls -la packages/h3/src/*.test.* 2>/dev/null
ls -la packages/h3/spec/*.spec.* 2>/dev/null
echo -e "\n=== Sample of main test file ==="
head -50 packages/h3/src/index.test.tsLength of output: 3631
🏁 Script executed:
#!/bin/bash
# Check for test scripts at workspace root and CI configuration
echo "=== Root package.json scripts ==="
cat package.json | grep -A 20 '"scripts"' | head -25
echo -e "\n=== Checking for vitest config in packages/h3 ==="
ls -la packages/h3/vitest.* packages/h3/vite.* 2>/dev/null || echo "No vitest/vite config found in packages/h3"
echo -e "\n=== Checking root vitest config ==="
ls -la vitest.* vite.* 2>/dev/null | head -5
echo -e "\n=== Looking for CI workflow test command ==="
find .github -name "*.yml" -o -name "*.yaml" 2>/dev/null | xargs grep -l "test" 2>/dev/null | head -2
echo -e "\n=== Sample CI workflow ==="
find .github/workflows -name "*.yml" 2>/dev/null | head -1 | xargs cat 2>/dev/null | grep -A 5 "test"Length of output: 2739
Verify h3 v2.0.1-rc.5 compatibility before merging — confirmed breaking changes require testing.
Investigation confirms significant breaking changes in h3 v1→v2: ESM-only/Node >= 20.11 requirement, web-standards rewrite using Request/Response/URL/Headers, router API changes, middleware path matching changes, and event.path semantics changes.
Your code directly imports and uses affected h3 APIs:
toWebRequest()from h3H3Eventtype (test mocks assume specific structure withweb.requestandnode.req)AppOptionstype- Module augmentation on
h3
Tests exist (index.test.ts, spec/integration.spec.ts, spec/e2e.spec.ts) and the root pnpm test script will run them via vitest. However, before merging to a pre-release version:
- Confirm tests pass: Run
pnpm testand verify all h3 package tests pass with h3 v2.0.1-rc.5 - Verify API compatibility: Ensure
H3Eventstructure,toWebRequest(), andAppOptionsmatch v2 API in your code - Consider stability: Evaluate whether to wait for stable h3 v2.0.0 release rather than using rc.5 to avoid mid-development breaking changes
|
Thank you for your contribution! |
Description
I tested
@intlify/h3with h3 v2 and it seems to be working, but I saw the dependency was still h3 v1.Summary by CodeRabbit