Skip to content
Source
Sign inSign up
TanStack/router

fix: revert alias handling for nitro-v2-vite-plugin #5378

Mergedschiller-manuel(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/5378/headmerged by schiller-manuel(GitHub profile, opens in a new tab)

the approach did not work with bun, bun only installs h3@v1 (it probably disregards v2 as it is still beta)

Summary by CodeRabbit

  • New Features

    • Added a CommonJS entry point for improved compatibility with CJS environments.
  • Refactor

    • Simplified SSR build configuration by removing custom runtime resolution logic.
  • Chores

    • Updated HTTP framework dependency to a v2-compatible alias and cleaned up legacy v1 references.
    • Adjusted build settings to rely on default CommonJS behavior.
  • Impact

    • Better interoperability with diverse build systems.
    • More predictable server-side builds with fewer edge cases.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: nitro-v2-vite-plugin

    3. Walkthrough

      Introduces a CommonJS entry for nitro-v2-vite-plugin, removes h3-v1 aliasing and resolve logic in its SSR build, and drops cjs override in its Vite config. start-server-core switches from direct h3 to an aliased h3-v2 dependency and updates corresponding imports. No public API shape changes.

      Changes

      Cohort / File(s)Summary
      Nitro Vite plugin packaging/config
      packages/nitro-v2-vite-plugin/package.json, packages/nitro-v2-vite-plugin/vite.config.ts
      Added main "dist/cjs/index.cjs" for CJS; removed explicit cjs:false in Vite config. Dropped h3-v1 dependency.
      Nitro Vite plugin SSR build logic
      packages/nitro-v2-vite-plugin/src/index.ts
      Removed dynamic require and custom resolveId mapping h3→h3-v1; rollupConfig.plugins now only includes virtualBundlePlugin(ssrBundle).
      Start-server-core dependency and imports
      packages/start-server-core/package.json, packages/start-server-core/src/request-response.ts
      Replaced dependency "h3" with alias "h3-v2" (npm:h3@2.0.0-beta.4); updated imports to source from h3-v2.

      Sequence Diagram(s)

      sequenceDiagram
        autonumber
        participant Dev as Vite/Rollup
        participant Plugin as nitro-v2-vite-plugin
        participant Resolver as Module Resolver
      
        Note over Dev,Resolver: SSR build entry resolution
      
        rect rgba(200,230,255,0.25)
          Note over Plugin: Previous flow
          Dev->>Plugin: configure rollup
          Plugin->>Resolver: resolveId hook (h3 → h3-v1)
          Resolver-->>Dev: module id (h3-v1)
        end
      
        rect rgba(200,255,200,0.25)
          Note over Plugin: New flow
          Dev->>Plugin: configure rollup
          Plugin->>Dev: plugins = [virtualBundlePlugin]
          Dev->>Resolver: standard resolution (no h3 remap)
          Resolver-->>Dev: module id (as declared)
        end

      Estimated code review effort

      🎯 2 (Simple) | ⏱️ ~10 minutes

      • TanStack/router#5370 — Earlier addition of h3-v1 alias and runtime resolve mapping in the nitro-v2-vite-plugin; this PR removes that logic.
      • TanStack/router#5281 — Prior switch in start-server-core from direct h3 to aliased h3-v2 and matching import updates, mirroring this change.

      Poem

      I hop through builds with tidy grace, No more remaps in my race. CJS burrow neatly spun, h3-v2—new morning sun. With simpler paths and lighter load, I thump my paws on the shipping road. 🐇✨

      Pre-merge checks and finishing touches

      ❌ Failed checks (1 warning)
      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
      ✅ Passed checks (2 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title Check✅ PassedThe title accurately describes the primary change by specifying that alias handling for the nitro-v2-vite-plugin is being reverted, which aligns with the PR’s modifications to remove dynamic h3 alias logic. It is concise, clear, and references the specific package affected, enabling reviewers to understand the main intent at a glance. The phrasing avoids extraneous detail while still conveying the essential action.
      ✨ Finishing touches
      • 📝 Generate docstrings
        🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Post copyable unit tests in a comment
      • Commit unit tests in branch `rever-h3-alias`

      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    4. View your CI Pipeline Execution ↗ for commit c5581b08d28f83484c0b49687d8ab169ccdd2086

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded4m 9sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded22sView ↗

      ☁️ Nx Cloud last updated this comment at 2025-10-05 20:27:22 UTC

    5. More templates

      @tanstack/arktype-adapter

      npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5378

      @tanstack/directive-functions-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5378

      @tanstack/eslint-plugin-router

      npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5378

      @tanstack/history

      npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5378

      @tanstack/nitro-v2-vite-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5378

      @tanstack/react-router

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5378

      @tanstack/react-router-devtools

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5378

      @tanstack/react-router-ssr-query

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5378

      @tanstack/react-start

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5378

      @tanstack/react-start-client

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5378

      @tanstack/react-start-server

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5378

      @tanstack/router-cli

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5378

      @tanstack/router-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5378

      @tanstack/router-devtools

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5378

      @tanstack/router-devtools-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5378

      @tanstack/router-generator

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5378

      @tanstack/router-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5378

      @tanstack/router-ssr-query-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5378

      @tanstack/router-utils

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5378

      @tanstack/router-vite-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5378

      @tanstack/server-functions-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5378

      @tanstack/solid-router

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5378

      @tanstack/solid-router-devtools

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5378

      @tanstack/solid-start

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5378

      @tanstack/solid-start-client

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5378

      @tanstack/solid-start-server

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5378

      @tanstack/start-client-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5378

      @tanstack/start-plugin-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5378

      @tanstack/start-server-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5378

      @tanstack/start-static-server-functions

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5378

      @tanstack/start-storage-context

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5378

      @tanstack/valibot-adapter

      npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5378

      @tanstack/virtual-file-routes

      npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5378

      @tanstack/zod-adapter

      npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5378

      commit: c5581b0

    6. Actionable comments posted: 0

      Caution

      Some comments are outside the diff and can’t be posted inline due to platform limitations.

      ⚠️ Outside diff range comments (1)
      packages/nitro-v2-vite-plugin/src/index.ts (1)

      117-119: Fix h3 import version mismatch in virtual entry (packages/nitro-v2-vite-plugin/src/index.ts:117–119) nitropack depends on h3 v1.15.4 which doesn’t export fromWebHandler; this import will fail at runtime. Align your build on h3 v2 (e.g. update dependency or add an alias/peer-declaration for h3 v2).

      🧹 Nitpick comments (1)
      packages/start-server-core/package.json (1)

      71-71: Verify the version downgrade from beta.5 to beta.4.

      The dependency was downgraded from h3@2.0.0-beta.5 to h3@2.0.0-beta.4. Please confirm this downgrade is intentional and document the reason (e.g., breaking changes in beta.5, compatibility issues with Bun, or other considerations).

      Additionally, consider the stability implications of depending on a beta version. If this is intended for production use, evaluate whether the beta status aligns with your stability requirements.

      📜 Review details

      Configuration used: CodeRabbit UI

      Review profile: CHILL

      Plan: Pro

      📥 Commits

      Reviewing files that changed from the base of the PR and between e94e9c7321ce8ba213ee421b4e1369429ffea384 and c5581b08d28f83484c0b49687d8ab169ccdd2086.

      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing (5)
      • packages/nitro-v2-vite-plugin/package.json (2 hunks)
      • packages/nitro-v2-vite-plugin/src/index.ts (1 hunks)
      • packages/nitro-v2-vite-plugin/vite.config.ts (0 hunks)
      • packages/start-server-core/package.json (1 hunks)
      • packages/start-server-core/src/request-response.ts (1 hunks)
      💤 Files with no reviewable changes (1)
      • packages/nitro-v2-vite-plugin/vite.config.ts
      🧰 Additional context used
      📓 Path-based instructions (3)
      **/package.json

      📄 CodeRabbit inference engine (AGENTS.md)

      Use workspace:* protocol for internal dependencies in package.json files

      Files:

      • packages/start-server-core/package.json
      • packages/nitro-v2-vite-plugin/package.json
      packages/{*-start,start-*}/**

      📄 CodeRabbit inference engine (AGENTS.md)

      Name and place Start framework packages under packages/-start/ or packages/start-/

      Files:

      • packages/start-server-core/package.json
      • packages/start-server-core/src/request-response.ts
      **/*.{ts,tsx}

      📄 CodeRabbit inference engine (AGENTS.md)

      Use TypeScript in strict mode with extensive type safety across the codebase

      Files:

      • packages/nitro-v2-vite-plugin/src/index.ts
      • packages/start-server-core/src/request-response.ts
      ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
      • GitHub Check: Test
      • GitHub Check: Preview
      🔇 Additional comments (4)
      packages/start-server-core/src/request-response.ts (1)

      22-22: LGTM! Import source correctly updated to h3-v2 alias.

      The change aligns with the PR objective to migrate away from h3-v1 aliasing. All imported functions are retained in h3 v2 with backward-compatible APIs.

      Based on learnings

      packages/nitro-v2-vite-plugin/package.json (2)

      64-64: LGTM! Removal of h3-v1 dependency aligns with PR objective.

      Removing the h3-v1 alias resolves the Bun compatibility issue mentioned in the PR description, where Bun only installs h3@v1 and disregards the h3@v2 beta.


      43-43: Verify CommonJS bundle output Ensure vite build actually generates dist/cjs/index.cjs—for example, add build.lib.formats = ['cjs','es'] in packages/nitro-v2-vite-plugin/vite.config.ts—and confirm the file exists post-build.

      packages/nitro-v2-vite-plugin/src/index.ts (1)

      113-113: LGTM! Simplified rollup plugin configuration.

      Removing the h3-v1 resolution logic aligns with the PR objective to revert the alias handling that didn't work with Bun.

    7. I get this error with '@tanstack/nitro-v2-vite-plugin': ^1.132.40

      Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'h3-v2' imported from /app/.output/server/node_modules/@tanstack/start-server-core/dist/esm/request-response.js
          at Object.getPackageJSONURL (node:internal/modules/package_json_reader:316:9)
          at packageResolve (node:internal/modules/esm/resolve:768:81)
          at moduleResolve (node:internal/modules/esm/resolve:858:18)
          at defaultResolve (node:internal/modules/esm/resolve:990:11)
          at #cachedDefaultResolve (node:internal/modules/esm/loader:755:20)
          at ModuleLoader.resolve (node:internal/modules/esm/loader:732:38)
          at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:317:38)
          at #link (node:internal/modules/esm/module_job:208:49)
          at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
        code: 'ERR_MODULE_NOT_FOUND',
        routerCode: 'BEFORE_LOAD'
      }

Sign in to join this conversation.