Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node_version: [18, 20, 22, 24]
node_version: [20, 22, 24]
include:
# Active LTS + other OS
- os: macos-latest
Expand Down Expand Up @@ -81,9 +81,6 @@ jobs:
# does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
run: pnpm playwright install chromium

- if: matrix.node_version == '18'
run: pnpm i -D [email protected] -w

- name: Build
run: pnpm run build

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"type": "module",
"engines": {
"node": "^14.18.0 || >=16.0.0"
"node": "^20.19.0 || >=22.12.0"
},
"packageManager": "[email protected]",
"homepage": "https://github.com/vitejs/vite-plugin-react/",
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-react-oxc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Require Node 20.19+, 22.12+

This plugin now requires Node 20.19+ or 22.12+.

## 0.3.0 (2025-07-18)

### Add HMR support for compound components ([#518](https://github.com/vitejs/vite-plugin-react/pull/518))
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-react-oxc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
"dist"
],
"type": "module",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"scripts": {
"dev": "tsdown --watch",
"build": "tsdown",
"prepublishOnly": "npm run build"
},
"engines": {
"node": ">=20.0.0"
"node": "^20.19.0 || >=22.12.0"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react-oxc/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
"target": "ES2020",
"module": "ES2020",
"target": "es2023",
"module": "preserve",
"moduleResolution": "bundler",
"strict": true,
"declaration": true,
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-react-oxc/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from 'tsdown'

export default defineConfig({
entry: 'src/index.ts',
dts: true,
copy: [
{
from: 'node_modules/@vitejs/react-common/refresh-runtime.js',
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-react-swc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Require Node 20.19+, 22.12+

This plugin now requires Node 20.19+ or 22.12+.

## 3.11.0 (2025-07-18)

### Add HMR support for compound components ([#518](https://github.com/vitejs/vite-plugin-react/pull/518))
Expand Down
3 changes: 3 additions & 0 deletions packages/plugin-react-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"build": "tsdown",
"test": "playwright test"
},
"engines": {
"node": "^20.19.0 || >=22.12.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vitejs/vite-plugin-react.git",
Expand Down
9 changes: 9 additions & 0 deletions packages/plugin-react-swc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,12 @@ const transformWithOptions = async (
}

export default react

// Compat for require
function pluginForCjs(this: unknown, options: Options): Plugin[] {
return react.call(this, options)
}
Object.assign(pluginForCjs, {
default: pluginForCjs,
})
export { pluginForCjs as 'module.exports' }
23 changes: 1 addition & 22 deletions packages/plugin-react-swc/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import packageJSON from './package.json' with { type: 'json' }

export default defineConfig({
entry: 'src/index.ts',
format: ['esm', 'cjs'],
dts: true,
tsconfig: './tsconfig.src.json', // https://github.com/sxzz/rolldown-plugin-dts/issues/55
copy: [
Expand All @@ -21,18 +20,6 @@ export default defineConfig({
to: 'dist/README.md',
},
],
outputOptions(outputOpts, format) {
if (format === 'cjs') {
outputOpts.footer = (chunk) => {
// don't append to dts files
if (chunk.fileName.endsWith('.cjs')) {
return 'module.exports.default = module.exports'
}
return ''
}
}
return outputOpts
},
onSuccess() {
writeFileSync(
'dist/package.json',
Expand All @@ -46,15 +33,7 @@ export default defineConfig({
key !== 'private',
),
),
main: 'index.cjs',
types: 'index.d.ts',
module: 'index.js',
exports: {
'.': {
require: './index.cjs',
import: './index.js',
},
},
exports: './index.js',
},
null,
2,
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Require Node 20.19+, 22.12+

This plugin now requires Node 20.19+ or 22.12+.

## 4.7.0 (2025-07-18)

### Add HMR support for compound components ([#518](https://github.com/vitejs/vite-plugin-react/pull/518))
Expand Down
12 changes: 2 additions & 10 deletions packages/plugin-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,15 @@
"dist"
],
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"exports": "./dist/index.js",
"scripts": {
"dev": "tsdown --watch",
"build": "tsdown",
"prepublishOnly": "npm run build",
"test-unit": "vitest run"
},
"engines": {
"node": "^14.18.0 || >=16.0.0"
"node": "^20.19.0 || >=22.12.0"
},
"repository": {
"type": "git",
Expand Down
9 changes: 9 additions & 0 deletions packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,15 @@ export default function viteReact(opts: Options = {}): Plugin[] {

viteReact.preambleCode = preambleCode

// Compat for require
function viteReactForCjs(this: unknown, options: Options): Plugin[] {
return viteReact.call(this, options)
}
Object.assign(viteReactForCjs, {
default: viteReactForCjs,
})
export { viteReactForCjs as 'module.exports' }

function canSkipBabel(
plugins: ReactBabelOptions['plugins'],
babelOptions: ReactBabelOptions,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
"target": "ES2020",
"module": "ES2020",
"target": "es2023",
"module": "preserve",
"moduleResolution": "bundler",
"strict": true,
"declaration": true,
Expand Down
14 changes: 1 addition & 13 deletions packages/plugin-react/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,11 @@ import { defineConfig } from 'tsdown'

export default defineConfig({
entry: 'src/index.ts',
format: ['esm', 'cjs'],
dts: true,
copy: [
{
from: 'node_modules/@vitejs/react-common/refresh-runtime.js',
to: 'dist/refresh-runtime.js',
},
],
outputOptions(outputOpts, format) {
if (format === 'cjs') {
outputOpts.footer = (chunk) => {
// don't append to dts files
if (chunk.fileName.endsWith('.cjs')) {
return 'module.exports.default = module.exports'
}
return ''
}
}
return outputOpts
},
})
6 changes: 3 additions & 3 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"include": ["*.ts", "**/__tests__/*.ts", "**/vite.config.ts"],
"exclude": ["**/dist/**"],
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"target": "ES2023",
"module": "preserve",
"outDir": "dist",
"baseUrl": ".",
"allowJs": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"moduleResolution": "Node",
"moduleResolution": "bundler",
"skipLibCheck": true,
"noEmit": true,
"noUnusedLocals": true,
Expand Down
Loading