Skip to content

Commit b9efa3f

Browse files
authored
refactor!: bump required node version to 20.19+, 22.12+ and drop CJS build (#583)
1 parent bfd434f commit b9efa3f

File tree

16 files changed

+48
-59
lines changed

16 files changed

+48
-59
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
strategy:
3030
matrix:
3131
os: [ubuntu-latest]
32-
node_version: [18, 20, 22, 24]
32+
node_version: [20, 22, 24]
3333
include:
3434
# Active LTS + other OS
3535
- os: macos-latest
@@ -81,9 +81,6 @@ jobs:
8181
# does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
8282
run: pnpm playwright install chromium
8383

84-
- if: matrix.node_version == '18'
85-
run: pnpm i -D [email protected] -w
86-
8784
- name: Build
8885
run: pnpm run build
8986

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"private": true,
44
"type": "module",
55
"engines": {
6-
"node": "^14.18.0 || >=16.0.0"
6+
"node": "^20.19.0 || >=22.12.0"
77
},
88
"packageManager": "[email protected]",
99
"homepage": "https://github.com/vitejs/vite-plugin-react/",

packages/plugin-react-oxc/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Require Node 20.19+, 22.12+
6+
7+
This plugin now requires Node 20.19+ or 22.12+.
8+
59
## 0.3.0 (2025-07-18)
610

711
### Add HMR support for compound components ([#518](https://github.com/vitejs/vite-plugin-react/pull/518))

packages/plugin-react-oxc/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020
"dist"
2121
],
2222
"type": "module",
23-
"types": "./dist/index.d.ts",
2423
"exports": "./dist/index.js",
2524
"scripts": {
2625
"dev": "tsdown --watch",
2726
"build": "tsdown",
2827
"prepublishOnly": "npm run build"
2928
},
3029
"engines": {
31-
"node": ">=20.0.0"
30+
"node": "^20.19.0 || >=22.12.0"
3231
},
3332
"repository": {
3433
"type": "git",

packages/plugin-react-oxc/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"include": ["src"],
33
"compilerOptions": {
44
"outDir": "dist",
5-
"target": "ES2020",
6-
"module": "ES2020",
5+
"target": "es2023",
6+
"module": "preserve",
77
"moduleResolution": "bundler",
88
"strict": true,
99
"declaration": true,

packages/plugin-react-oxc/tsdown.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineConfig } from 'tsdown'
22

33
export default defineConfig({
44
entry: 'src/index.ts',
5+
dts: true,
56
copy: [
67
{
78
from: 'node_modules/@vitejs/react-common/refresh-runtime.js',

packages/plugin-react-swc/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Require Node 20.19+, 22.12+
6+
7+
This plugin now requires Node 20.19+ or 22.12+.
8+
59
## 3.11.0 (2025-07-18)
610

711
### Add HMR support for compound components ([#518](https://github.com/vitejs/vite-plugin-react/pull/518))

packages/plugin-react-swc/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"build": "tsdown",
2020
"test": "playwright test"
2121
},
22+
"engines": {
23+
"node": "^20.19.0 || >=22.12.0"
24+
},
2225
"repository": {
2326
"type": "git",
2427
"url": "git+https://github.com/vitejs/vite-plugin-react.git",

packages/plugin-react-swc/src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,12 @@ const transformWithOptions = async (
292292
}
293293

294294
export default react
295+
296+
// Compat for require
297+
function pluginForCjs(this: unknown, options: Options): Plugin[] {
298+
return react.call(this, options)
299+
}
300+
Object.assign(pluginForCjs, {
301+
default: pluginForCjs,
302+
})
303+
export { pluginForCjs as 'module.exports' }

packages/plugin-react-swc/tsdown.config.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import packageJSON from './package.json' with { type: 'json' }
44

55
export default defineConfig({
66
entry: 'src/index.ts',
7-
format: ['esm', 'cjs'],
87
dts: true,
98
tsconfig: './tsconfig.src.json', // https://github.com/sxzz/rolldown-plugin-dts/issues/55
109
copy: [
@@ -21,18 +20,6 @@ export default defineConfig({
2120
to: 'dist/README.md',
2221
},
2322
],
24-
outputOptions(outputOpts, format) {
25-
if (format === 'cjs') {
26-
outputOpts.footer = (chunk) => {
27-
// don't append to dts files
28-
if (chunk.fileName.endsWith('.cjs')) {
29-
return 'module.exports.default = module.exports'
30-
}
31-
return ''
32-
}
33-
}
34-
return outputOpts
35-
},
3623
onSuccess() {
3724
writeFileSync(
3825
'dist/package.json',
@@ -46,15 +33,7 @@ export default defineConfig({
4633
key !== 'private',
4734
),
4835
),
49-
main: 'index.cjs',
50-
types: 'index.d.ts',
51-
module: 'index.js',
52-
exports: {
53-
'.': {
54-
require: './index.cjs',
55-
import: './index.js',
56-
},
57-
},
36+
exports: './index.js',
5837
},
5938
null,
6039
2,

0 commit comments

Comments
 (0)