Skip to content

feat(react)!: remove babel - #1123

Merged
sapphi-red merged 22 commits into
mainfrom
feat/react-remove-babel
Mar 3, 2026
Merged

feat(react)!: remove babel#1123
sapphi-red merged 22 commits into
mainfrom
feat/react-remove-babel

Conversation

@sapphi-red

@sapphi-red sapphi-red commented Feb 27, 2026

Copy link
Copy Markdown
Member

Description

Built on top of #1124

In Vite 8 (currently beta), react refresh transform can be handled by Oxc. This means there's no transform that uses babel by default.
To reduce the install size, I think we should remove babel from the dependency of @vitejs/plugin-react.

The @rolldown/plugin-babel package lives at https://github.com/rolldown/plugins.

context: #1114

@sapphi-red
sapphi-red force-pushed the feat/react-remove-babel branch from 7a9ebf1 to a20730e Compare February 27, 2026 08:40
@sapphi-red
sapphi-red changed the base branch from main to refactor/react-drop-vite7-and-below-support February 27, 2026 08:40

@ArnaudBarre ArnaudBarre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks cool, thanks for the cleanup, I'm happy I will be able stop downloading babel!
We need to updates the docs (both Readmes in the repo and vite.dev)
I think we should also add a section on how to add babel to a Vite 8 project, promoting this new plugin and all the possibilities for filtering.

Comment thread playground/include-node-modules/vite.config.ts
function viteReactForCjs(this: unknown, options: Options): Plugin[] {
return viteReact.call(this, options)
}
Object.assign(viteReactForCjs, {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this needed when supporting only Vite 8+ which means require(esm) IIRM?

@sapphi-red sapphi-red Mar 2, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is needed to keep the value of require('@vitejs/plugin-react'). If we remove this, the config has to be:

const react = require('@vitejs/plugin-react')

module.exports = {
  plugins: [react.default()] // instead of `react()`
}
Comment thread playground/compiler/package.json Outdated
Comment thread packages/plugin-rsc/e2e/react-compiler.test.ts Outdated
Base automatically changed from refactor/react-drop-vite7-and-below-support to main March 2, 2026 04:00
@sapphi-red
sapphi-red marked this pull request as ready for review March 2, 2026 05:44
Comment thread packages/plugin-rsc/src/plugin.ts Outdated
Comment thread packages/plugin-react/README.md Outdated
Comment thread packages/plugin-react/README.md Outdated
"noUnusedLocals": true,
"esModuleInterop": true
"esModuleInterop": true,
"rootDir": ".",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is rootDir needed? I thought this would allow importing it like import "src/any-file-inside-project" without type error and I didn't like that before.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is needed, otherwise I get the following error:

error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'path/to/vite-plugin-react/packages/plugin-react/package.json'. Supply the rootDir compiler option to disambiguate.

I thought this would allow importing it like import "src/any-file-inside-project" without type error

I guess you are confused with baseUrl.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah good to know. Indeed, baseUrl is the one I hated 😅

@sapphi-red

Copy link
Copy Markdown
Member Author

I'll cut a beta version with this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants