Skip to content

refactor: add rolldown as dependency#4002

Merged
pi0 merged 3 commits intomainfrom
refactor/rolldown-dep
Feb 5, 2026
Merged

refactor: add rolldown as dependency#4002
pi0 merged 3 commits intomainfrom
refactor/rolldown-dep

Conversation

@pi0
Copy link
Member

@pi0 pi0 commented Feb 5, 2026

Currently nitro has optional peer dependency on rolldown + oxc-transform (for OpenAPI route meta) and oxc-minify for legacy.

Vite v8 will be having dependency on rolldown, by adding rolldown dependency to nitro:

  • Nitro + Vite => The install size will be practically reduced as we share rolldown dep
  • Nitro CLI for API => Nitro has built-in rolldown dependency which increases DX!

Important

Current PR depends on rolldown/experimental imports. Although i tried to make use of dynamic imports to reduce chance of fatal issues in case of breaking changes, we will be waiting and immediately update to better rolldown/ subpath export when available.

/cc @TheAlexLichter @nitrojs/vite

@vercel
Copy link

vercel bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nitro.build Ready Ready Preview, Comment Feb 5, 2026 8:10pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Replaces oxc-minify/oxc-transform with rolldown, elevates rolldown to runtime dependency, and converts several build plugins and config to async with dynamic imports; updates public types to use rolldown equivalents.

Changes

Cohort / File(s) Summary
Dependency Migration
package.json
Removed oxc-minify & oxc-transform; added/moved rolldown to dependencies with normalized ^1.0.0-rc.3.
Plugin Async Refactoring
src/build/plugins/oxc.ts, src/build/plugins/route-meta.ts
Converted oxc and routeMeta to async functions and replaced static imports with dynamic await import("rolldown/experimental") to obtain transformSync/minifySync.
Plugin Orchestration / Rollup Config
src/build/plugins.ts, src/build/rollup/config.ts
Now await the async plugin factories (routeMeta(nitro), oxc({...})) before pushing into plugin arrays; minor addition of a cwd transform option and a TS expect-error comment.
Type Updates
src/types/build.ts
Replaced oxc-minify/oxc-transform type imports with rolldown equivalents and updated OXCOptions.minify and OXCOptions.transform (refined jsx typing).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with 'refactor:' prefix and clearly describes the main change of adding rolldown as a dependency.
Description check ✅ Passed The description is directly related to the changeset, providing context about the dependency migration from oxc packages to rolldown and its benefits.

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

✨ 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 refactor/rolldown-dep

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.

@pi0 pi0 changed the title build: add rolldown as dependency refactor: add rolldown as dependency Feb 5, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@package.json`:
- Line 78: The package.json lists "rolldown" in dependencies but it is a
build-time tool used only by Nitro's build process (see src/build/rolldown/ and
build plugins) and should be moved to devDependencies; update package.json by
removing "rolldown" from "dependencies" and adding the same version entry under
"devDependencies" (preserve the ^1.0.0-rc.3 version and any optionalPeerDep
usage), then run an install to update lockfile so consumers no longer get
rolldown at runtime.
🧹 Nitpick comments (1)
src/build/plugins/oxc.ts (1)

1-9: Align MinifyOptions type import to match the public API source.

OXCOptions in src/types/build.ts uses RolldownMinifyOptions from rolldown, but this file imports MinifyOptions from rolldown/experimental. To maintain consistency and avoid potential type divergence, import from the stable rolldown export instead, which is the canonical source for this type.

♻️ Suggested alignment
-import type { MinifyOptions } from "rolldown/experimental";
+import type { MinifyOptions } from "rolldown";
 import type { OXCOptions } from "nitro/types";
 import type { Plugin } from "rollup";
 
 export async function oxc(
   options: OXCOptions & { sourcemap: boolean; minify: boolean | MinifyOptions }
 ): Promise<Plugin> {

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/build/rollup/config.ts`:
- Around line 28-29: The code passes an unsupported cwd option to
rolldown.transformSync (cwd: nitro.options.rootDir) with a `@ts-expect-error`;
remove this invalid option and the ts-expect-error and either (a) if path
resolution is required, move/configure the cwd at the InputOptions level used by
rolldown() / build() or (b) configure path resolution within the relevant plugin
instead of passing cwd to transformSync; update usages around transformSync and
nitro.options.rootDir accordingly so no ignored/unsupported options remain.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nitrojs/nitro@4002

commit: 05a235d

@pi0 pi0 merged commit 6c80c11 into main Feb 5, 2026
12 checks passed
@pi0 pi0 deleted the refactor/rolldown-dep branch February 5, 2026 20:15
@sandros94
Copy link
Contributor

sandros94 commented Feb 6, 2026

EDIT: Fixed in d3b1f7b

@pi0 shouldn't both output options be optional?

nitro/src/types/build.ts

Lines 13 to 19 in db30877

export type RollupConfig = RollupInputOptions & {
output: RollupOutputOptions;
};
export type RolldownConfig = RolldownInputOptions & {
output: RolldownOutputOptions;
};

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.

2 participants