Skip to content

Commit a0f81c9

Browse files
antfukiaking
andauthored
feat: migrate to ESM (vuejs#645) (vuejs#659)
close vuejs#645 Co-authored-by: Kia King Ishii <[email protected]>
1 parent bae47f7 commit a0f81c9

27 files changed

+960
-1056
lines changed

__tests__/tsconfig.json

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
{
2+
"extends": "../tsconfig.json",
23
"compilerOptions": {
34
"baseUrl": ".",
4-
"module": "esnext",
5-
"moduleResolution": "node",
6-
"strict": true,
7-
"noUnusedLocals": true,
8-
"skipLibCheck": true,
9-
"esModuleInterop": true,
10-
"lib": ["ESNext", "DOM"],
11-
"types": ["node", "vitest/global"],
5+
"types": ["node", "vitest/globals"],
126
"paths": {
137
"node/*": ["../src/node/*"],
148
"client/*": ["../src/client/*"]

__tests__/vitest.config.js

-10
This file was deleted.

__tests__/vitest.config.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { dirname, resolve } from 'path'
2+
import { fileURLToPath } from 'url'
3+
import { defineConfig } from 'vite'
4+
5+
const dir = dirname(fileURLToPath(import.meta.url))
6+
7+
export default defineConfig({
8+
resolve: {
9+
alias: {
10+
node: resolve(dir, '../src/node'),
11+
client: resolve(dir, '../src/client')
12+
}
13+
},
14+
test: {
15+
globals: true
16+
}
17+
})

api-extractor.client.json

-53
This file was deleted.

api-extractor.node.json

-53
This file was deleted.

bin/vitepress.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env node
2-
require('../dist/node/cli')
2+
import('../dist/node/cli.js')

package.json

+38-34
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
{
22
"name": "vitepress",
33
"version": "1.0.0-draft.4",
4+
"type": "module",
45
"packageManager": "[email protected]",
56
"description": "Vite & Vue powered static site generator",
67
"main": "dist/node/index.js",
7-
"typings": "types/index.d.ts",
8+
"types": "types/index.d.ts",
9+
"exports": {
10+
".": {
11+
"types": "./types/index.d.ts",
12+
"import": "./dist/node/index.js",
13+
"require": "./dist/node-cjs/index.cjs"
14+
},
15+
"./dist/client/*": "./dist/client/*"
16+
},
817
"bin": {
918
"vitepress": "bin/vitepress.js"
1019
},
@@ -31,27 +40,22 @@
3140
"url": "https://github.com/vuejs/vitepress/issues"
3241
},
3342
"engines": {
34-
"node": ">=14.0.0"
43+
"node": ">=14.6.0"
3544
},
3645
"scripts": {
37-
"dev": "run-s dev-shared dev-start",
46+
"dev": "rimraf dist && run-s dev-shared dev-start",
3847
"dev-start": "run-p dev-client dev-node dev-watch",
3948
"dev-client": "tsc -w -p src/client",
40-
"dev-node": "tsc -w -p src/node",
49+
"dev-node": "DEV=true pnpm run build-node -w",
4150
"dev-shared": "node scripts/copyShared",
4251
"dev-watch": "node scripts/watchAndCopy",
43-
"build": "run-s build-prepare build-client build-node build-types",
44-
"build-prepare": "rimraf -rf dist && node scripts/copyShared",
52+
"build": "run-s build-prepare build-client build-node",
53+
"build-prepare": "rimraf dist && node scripts/copyShared",
4554
"build-client": "tsc -p src/client && node scripts/copyClient",
46-
"build-node": "rollup -c scripts/rollup.config.js",
47-
"build-types": "run-s build-types-client build-types-node",
48-
"build-types-client": "tsc -p src/client --declaration --emitDeclarationOnly --outDir dist/temp && api-extractor run -c api-extractor.client.json && rimraf dist/temp",
49-
"build-types-node": "tsc -p src/node --declaration --emitDeclarationOnly --outDir dist/temp && api-extractor run -c api-extractor.node.json && rimraf dist/temp",
50-
"lint": "run-s lint:js lint:ts",
51-
"lint:js": "prettier --check --write \"{bin,docs,scripts,src}/**/*.js\"",
52-
"lint:ts": "prettier --check --write --parser typescript \"{__tests__,src,docs,types}/**/*.ts\"",
53-
"test": "vitest run __tests__ -c __tests__/vitest.config.js --global",
54-
"test:all": "run-s lint test",
55+
"build-node": "rollup --config rollup.config.ts --configPlugin esbuild",
56+
"format": "prettier --write .",
57+
"lint": "pnpm run format",
58+
"test": "vitest -r __tests__",
5559
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
5660
"release": "node scripts/release.js",
5761
"docs": "run-p dev docs-dev",
@@ -60,18 +64,7 @@
6064
"docs-build": "run-s build docs-build-only",
6165
"docs-build-only": "node ./bin/vitepress build docs",
6266
"docs-serve": "node ./bin/vitepress serve docs",
63-
"ci-docs": "run-s build docs-build"
64-
},
65-
"gitHooks": {
66-
"pre-commit": "lint-staged"
67-
},
68-
"lint-staged": {
69-
"*.js": [
70-
"prettier --write"
71-
],
72-
"*.ts": [
73-
"prettier --parser=typescript --write"
74-
]
67+
"ci-docs": "run-s docs-build"
7568
},
7669
"dependencies": {
7770
"@docsearch/css": "^3.0.0",
@@ -84,11 +77,11 @@
8477
"vue": "3.2.33"
8578
},
8679
"devDependencies": {
87-
"@microsoft/api-extractor": "^7.23.1",
8880
"@rollup/plugin-alias": "^3.1.5",
8981
"@rollup/plugin-commonjs": "^20.0.0",
9082
"@rollup/plugin-json": "^4.1.0",
9183
"@rollup/plugin-node-resolve": "^13.0.4",
84+
"@rollup/plugin-replace": "^4.0.0",
9285
"@types/body-scroll-lock": "^3.1.0",
9386
"@types/compression": "^1.7.0",
9487
"@types/cross-spawn": "^6.0.2",
@@ -102,7 +95,7 @@
10295
"@types/minimist": "^1.2.2",
10396
"@types/node": "^15.6.1",
10497
"@types/polka": "^0.5.3",
105-
"chalk": "^4.1.1",
98+
"@types/prompts": "^2.0.14",
10699
"chokidar": "^3.5.1",
107100
"compression": "^1.7.4",
108101
"conventional-changelog-cli": "^2.1.1",
@@ -112,10 +105,9 @@
112105
"enquirer": "^2.3.6",
113106
"esbuild": "^0.14.0",
114107
"escape-html": "^1.0.3",
115-
"execa": "^5.0.0",
108+
"execa": "^6.1.0",
116109
"fast-glob": "^3.2.7",
117110
"fs-extra": "^10.0.0",
118-
"globby": "^11.0.3",
119111
"gray-matter": "^4.0.3",
120112
"lint-staged": "^11.0.0",
121113
"lru-cache": "^6.0.0",
@@ -129,16 +121,20 @@
129121
"minimist": "^1.2.5",
130122
"npm-run-all": "^4.1.5",
131123
"ora": "^5.4.0",
124+
"picocolors": "^1.0.0",
132125
"polka": "^0.5.2",
133126
"prettier": "^2.3.0",
127+
"prompts": "^2.4.2",
134128
"rimraf": "^3.0.2",
135129
"rollup": "^2.56.3",
130+
"rollup-plugin-dts": "^4.2.2",
136131
"rollup-plugin-esbuild": "^4.8.2",
137132
"semver": "^7.3.5",
133+
"simple-git-hooks": "^2.7.0",
138134
"sirv": "^1.0.12",
139-
"typescript": "^4.6.4",
140-
"vitest": "^0.10.4",
141-
"yorkie": "^2.0.0"
135+
"supports-color": "^9.2.2",
136+
"typescript": "^4.7.2",
137+
"vitest": "^0.10.4"
142138
},
143139
"pnpm": {
144140
"peerDependencyRules": {
@@ -149,5 +145,13 @@
149145
"@types/react"
150146
]
151147
}
148+
},
149+
"simple-git-hooks": {
150+
"pre-commit": "lint-staged"
151+
},
152+
"lint-staged": {
153+
"*": [
154+
"prettier --write --ignore-unknown"
155+
]
152156
}
153157
}

0 commit comments

Comments
 (0)