Skip to content

Conversation

@joshblack
Copy link
Member

Follow up to: #7263 but a little smaller 👀

This PR updates our internal packages and styled-react to use rolldown over rollup. Rolldown is a rollup API compatible library that is using Rust for improved build performance ✨

Changelog

New

Changed

  • Update rollup usage to rolldown in:
    • doc-gen
    • mcp
    • styled-react
  • Add dependencies explicitly to styled-react/package.json so they were external to the build

Removed

Rollout strategy

  • Patch release
  • None; if selected, include a brief description as to why

For most libraries, this should be internal-only but styled-react I added a changeset for since we needed to add dependencies to package.json

Copilot AI review requested due to automatic review settings December 10, 2025 20:46
@joshblack joshblack requested a review from a team as a code owner December 10, 2025 20:46
@joshblack joshblack requested a review from jonrohan December 10, 2025 20:46
@changeset-bot
Copy link

changeset-bot bot commented Dec 10, 2025

🦋 Changeset detected

Latest commit: 6266921

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/styled-react 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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the build tooling for internal packages (doc-gen, mcp, and styled-react) from rollup to rolldown, a Rust-based bundler that provides improved build performance while maintaining rollup API compatibility. This is a follow-up to PR #7263, continuing the rolldown adoption strategy across the monorepo.

Key changes include:

  • Replacing rollup with rolldown in build scripts and configurations
  • Removing bundler plugins that rolldown handles natively (@rollup/plugin-commonjs, @rollup/plugin-node-resolve, @rollup/plugin-json)
  • Adding explicit dependencies to styled-react that were previously bundled

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/styled-react/script/build Updates build script to use rolldown CLI instead of rollup
packages/styled-react/rollup.config.js Deleted old rollup configuration including custom preserve-directives plugin
packages/styled-react/rolldown.config.js New rolldown configuration with simplified plugin setup
packages/styled-react/package.json Adds clsx, deepmerge, and focus-visible as dependencies; replaces rollup with rolldown in devDependencies
packages/mcp/rolldown.config.js Migrates from rollup to rolldown, removes unnecessary plugins
packages/mcp/package.json Updates build and watch scripts to use rolldown
packages/doc-gen/rolldown.config.js Migrates from rollup to rolldown with platform: 'node' configuration
packages/doc-gen/package.json Updates build scripts and reorders dependencies alphabetically
packages/doc-gen/tsconfig.json Includes vitest.config.mts for IDE support
packages/doc-gen/tsconfig.build.json Excludes test files from build output
package-lock.json Updates dependencies with rolldown and related packages
.changeset/chatty-windows-grin.md Documents the dependency additions to styled-react
Comments suppressed due to low confidence (1)

packages/mcp/rolldown.config.js:16

  • The doc-gen package config includes platform: 'node' (line 17), but this mcp config is missing it. Since mcp is also a Node.js package with a bin entry and uses Node.js APIs, it should also specify platform: 'node' to ensure rolldown properly handles Node.js built-ins and module resolution. Add platform: 'node' after the external property for consistency.

@@ -0,0 +1,48 @@
import babel from '@rollup/plugin-babel'
import {defineConfig} from 'rollup'
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

This import statement should use 'rolldown' instead of 'rollup'. The configuration file is named rolldown.config.js and the build scripts use the rolldown CLI, but defineConfig is being imported from the wrong package. This will cause the build to fail or use the wrong bundler configuration.

Suggested change
import {defineConfig} from 'rollup'
import {defineConfig} from 'rolldown'

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +29
plugins: [
typescript({
tsconfig: 'tsconfig.build.json',
}),
babel({
presets: ['@babel/preset-typescript', ['@babel/preset-react', {runtime: 'automatic'}]],
plugins: ['babel-plugin-styled-components'],
extensions: ['.ts', '.tsx'],
babelHelpers: 'bundled',
}),
],
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The previous rollup configuration included a custom "preserve-directives" plugin that explicitly prepended "use client" directives to output chunks. This plugin has been removed in the rolldown migration. The source file src/index.tsx contains a 'use client' directive that needs to be preserved in the built output for React Server Components compatibility. While rolldown may handle directives natively (as it's rollup-compatible), this should be verified by inspecting the built dist/index.js file to ensure "use client" appears at the top of the output. If the directive is missing, a similar custom plugin may need to be added to the rolldown configuration.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants