Skip to content

Commit 262fc7a

Browse files
authored
feat!: only support vite 6+ and node 18+ (#69)
1 parent 15f129a commit 262fc7a

File tree

3 files changed

+430
-426
lines changed

3 files changed

+430
-426
lines changed

build.config.ts

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
1+
import fs from 'node:fs/promises'
12
import { defineBuildConfig } from 'unbuild'
23

34
export default defineBuildConfig({
45
entries: ['src/index'],
56
externals: ['vite'],
67
clean: true,
7-
declaration: 'compatible',
8+
declaration: true,
89
rollup: {
910
emitCJS: true,
1011
inlineDependencies: true,
1112
esbuild: {
12-
target: 'node14.21.3',
13+
target: 'node18',
1314
},
1415
output: {
1516
generatedCode: {
1617
reservedNamesAsProps: false,
1718
},
1819
},
1920
},
21+
hooks: {
22+
async 'build:done'(ctx) {
23+
// Remove duplicated `dist/chunks/certificate.{cjs,mjs}` chunks
24+
// as both are only dynamically imported by the entrypoints. The
25+
// dynamic import can use the `.mjs` chunk only instead.
26+
await fs.rm('dist/chunks/certificate.cjs')
27+
const indexCjs = await fs.readFile('dist/index.cjs', 'utf8')
28+
const editedIndexCjs = indexCjs.replace(
29+
'chunks/certificate.cjs',
30+
'chunks/certificate.mjs',
31+
)
32+
if (indexCjs === editedIndexCjs) {
33+
throw new Error(
34+
'Failed to find `dist/chunks/certificate.cjs` in `dist/index.cjs`',
35+
)
36+
}
37+
await fs.writeFile('dist/index.cjs', editedIndexCjs)
38+
},
39+
},
2040
})

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
2525
},
2626
"engines": {
27-
"node": ">=14.21.3"
27+
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
2828
},
2929
"packageManager": "[email protected]",
3030
"repository": {
@@ -36,7 +36,7 @@
3636
},
3737
"homepage": "https://github.com/vitejs/vite-plugin-basic-ssl/#readme",
3838
"peerDependencies": {
39-
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
39+
"vite": "^6.0.0"
4040
},
4141
"devDependencies": {
4242
"@types/node": "^22.13.5",
@@ -49,6 +49,7 @@
4949
"prettier": "^3.5.2",
5050
"semver": "^7.7.1",
5151
"tsx": "^4.19.3",
52+
"typescript": "^5.7.3",
5253
"unbuild": "^3.3.1",
5354
"vite": "^6.2.0",
5455
"vitest": "^3.0.7"

0 commit comments

Comments
 (0)