Skip to content

Commit 56df545

Browse files
authored
refactor!: bump required node version to 20.19+, 22.12+ and drop CJS build (#596)
1 parent 12f2881 commit 56df545

File tree

14 files changed

+48
-111
lines changed

14 files changed

+48
-111
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ jobs:
3737
strategy:
3838
matrix:
3939
os: [ubuntu-latest]
40-
node_version: [18, 20]
40+
node_version: [20, 22, 24]
4141
include:
4242
# Active LTS + other OS
4343
- os: macos-latest
44-
node_version: 20
44+
node_version: 22
4545
- os: windows-latest
46-
node_version: 20
46+
node_version: 22
4747
fail-fast: false
4848

4949
name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}"

eslint.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ export default tseslint.config(
120120
'n/no-unsupported-features/es-builtins': [
121121
'error',
122122
{
123-
version: '^18.0.0 || >=20.0.0',
123+
version: '^20.19.0 || >=22.12.0',
124124
},
125125
],
126126
'n/no-unsupported-features/node-builtins': [
127127
'error',
128128
{
129-
version: '^18.0.0 || >=20.0.0',
129+
version: '^20.19.0 || >=22.12.0',
130130
},
131131
],
132132
'@typescript-eslint/explicit-module-boundary-types': 'off',
@@ -150,7 +150,7 @@ export default tseslint.config(
150150
'n/no-unsupported-features/node-builtins': [
151151
'error',
152152
{
153-
version: '^18.0.0 || >=20.0.0',
153+
version: '^20.19.0 || >=22.12.0',
154154
allowExperimental: true,
155155
},
156156
],

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": "^18.0.0 || >=20.0.0"
6+
"node": "^20.19.0 || >=22.12.0"
77
},
88
"homepage": "https://github.com/vitejs/vite-plugin-vue/",
99
"repository": {

packages/plugin-vue-jsx/build.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@ export default defineBuildConfig({
44
entries: ['src/index'],
55
clean: true,
66
declaration: true,
7-
rollup: {
8-
emitCJS: true,
9-
},
107
})

packages/plugin-vue-jsx/package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
{
22
"name": "@vitejs/plugin-vue-jsx",
33
"version": "4.2.0",
4-
"type": "commonjs",
4+
"type": "module",
55
"license": "MIT",
66
"author": "Evan You",
77
"files": [
88
"dist"
99
],
10-
"main": "./dist/index.cjs",
11-
"module": "./dist/index.mjs",
12-
"types": "./dist/index.d.ts",
1310
"exports": {
14-
".": {
15-
"import": "./dist/index.mjs",
16-
"require": "./dist/index.cjs"
17-
}
11+
".": "./dist/index.mjs",
12+
"./package.json": "./package.json"
1813
},
1914
"scripts": {
2015
"dev": "unbuild --stub",
21-
"build": "unbuild && pnpm run patch-cjs",
22-
"patch-cjs": "tsx ../../scripts/patchCJS.ts",
16+
"build": "unbuild",
2317
"prepublishOnly": "npm run build"
2418
},
2519
"engines": {
26-
"node": "^18.0.0 || >=20.0.0"
20+
"node": "^20.19.0 || >=22.12.0"
2721
},
2822
"repository": {
2923
"type": "git",

packages/plugin-vue-jsx/src/index.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '@rolldown/pluginutils'
1313
import type { Options } from './types'
1414

15-
export * from './types'
15+
export type * from './types'
1616

1717
const ssrRegisterHelperId = '/__vue-jsx-ssr-register-helper'
1818
const ssrRegisterHelperCode =
@@ -328,17 +328,17 @@ function isDefineComponentCall(
328328
)
329329
}
330330

331-
const hash =
332-
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- crypto.hash is supported in Node 21.7.0+, 20.12.0+
333-
crypto.hash ??
334-
((
335-
algorithm: string,
336-
data: crypto.BinaryLike,
337-
outputEncoding: crypto.BinaryToTextEncoding,
338-
) => crypto.createHash(algorithm).update(data).digest(outputEncoding))
339-
340331
function getHash(text: string) {
341-
return hash('sha256', text, 'hex').substring(0, 8)
332+
return crypto.hash('sha256', text, 'hex').substring(0, 8)
342333
}
343334

344335
export default vueJsxPlugin
336+
337+
// Compat for require
338+
function vueJsxPluginCjs(this: unknown, options: Options): Plugin {
339+
return vueJsxPlugin.call(this, options)
340+
}
341+
Object.assign(vueJsxPluginCjs, {
342+
default: vueJsxPluginCjs,
343+
})
344+
export { vueJsxPluginCjs as 'module.exports' }

packages/plugin-vue-jsx/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"exclude": ["**/*.spec.ts"],
44
"compilerOptions": {
55
"outDir": "dist",
6-
"target": "ES2020",
7-
"module": "ES2020",
8-
"moduleResolution": "Node",
6+
"target": "es2023",
7+
"module": "preserve",
8+
"moduleResolution": "bundler",
99
"strict": true,
1010
"declaration": true,
1111
"sourceMap": true,

packages/plugin-vue/build.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export default defineBuildConfig({
66
clean: true,
77
declaration: 'compatible',
88
rollup: {
9-
emitCJS: true,
109
inlineDependencies: true,
1110
},
1211
})

packages/plugin-vue/package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
{
22
"name": "@vitejs/plugin-vue",
33
"version": "6.0.0-beta.1",
4-
"type": "commonjs",
4+
"type": "module",
55
"license": "MIT",
66
"author": "Evan You",
77
"files": [
88
"dist"
99
],
10-
"main": "./dist/index.cjs",
11-
"module": "./dist/index.mjs",
12-
"types": "./dist/index.d.ts",
1310
"exports": {
14-
".": {
15-
"import": "./dist/index.mjs",
16-
"require": "./dist/index.cjs"
17-
}
11+
".": "./dist/index.mjs",
12+
"./package.json": "./package.json"
1813
},
1914
"scripts": {
2015
"dev": "unbuild --stub",
21-
"build": "unbuild && pnpm run patch-cjs",
22-
"patch-cjs": "tsx ../../scripts/patchCJS.ts",
16+
"build": "unbuild",
2317
"prepublishOnly": "npm run build"
2418
},
2519
"engines": {
26-
"node": "^18.0.0 || >=20.0.0"
20+
"node": "^20.19.0 || >=22.12.0"
2721
},
2822
"repository": {
2923
"type": "git",

packages/plugin-vue/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,3 +517,13 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin<Api> {
517517
function ensureArray<T>(value: T | T[]): T[] {
518518
return Array.isArray(value) ? value : [value]
519519
}
520+
521+
// Compat for require
522+
function vuePluginCjs(this: unknown, options: Options): Plugin<Api> {
523+
return vuePlugin.call(this, options)
524+
}
525+
Object.assign(vuePluginCjs, {
526+
default: vuePluginCjs,
527+
parseVueRequest,
528+
})
529+
export { vuePluginCjs as 'module.exports' }

packages/plugin-vue/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"exclude": ["**/*.spec.ts"],
44
"compilerOptions": {
55
"outDir": "dist",
6-
"target": "ES2020",
7-
"module": "ES2020",
8-
"moduleResolution": "node",
6+
"target": "es2023",
7+
"module": "preserve",
8+
"moduleResolution": "bundler",
99
"strict": true,
1010
"declaration": true,
1111
"sourceMap": true,

playground/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"include": ["."],
33
"exclude": ["**/dist/**"],
44
"compilerOptions": {
5-
"target": "ES2020",
5+
"target": "ES2023",
66
"module": "ESNext",
77
"outDir": "dist",
88
"baseUrl": ".",

scripts/patchCJS.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

scripts/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"$schema": "https://json.schemastore.org/tsconfig",
33
"include": ["."],
44
"compilerOptions": {
5-
"module": "ES2020",
6-
"target": "ES2020",
7-
"moduleResolution": "Node",
5+
"target": "es2023",
6+
"module": "preserve",
7+
"moduleResolution": "bundler",
88
"strict": true,
99
"esModuleInterop": true,
1010
"skipLibCheck": true,

0 commit comments

Comments
 (0)