Skip to content

Commit 6e18f16

Browse files
authored
feat(cli): export vite/client.d.ts (#142)
1 parent 72de4f3 commit 6e18f16

6 files changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ jobs:
146146
run: |
147147
pnpm test
148148
git diff --exit-code
149+
149150
install-e2e-test:
150151
name: vite install E2E test
151152
# FIXME: Error: spawnSync esbuild ENOTSOCK

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"copy-bindings": "cp -r ./packages/cli/binding/*.node ./packages/cli/dist && cp -r ./packages/cli/binding/*.node ./packages/global/dist",
1010
"install-global-cli": "npm install -g ./packages/global",
1111
"typecheck": "tsc -b tsconfig.json",
12-
"lint": "vite lint",
12+
"lint": "vite lint && vite run typecheck",
1313
"test": "vite test && pnpm -r snap-test",
1414
"prepare": "husky"
1515
},

packages/cli/build.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ const { options } = parseJsonSourceFileConfigFileContent(tsconfig, sys, projectD
5959

6060
const host = createCompilerHost(options);
6161

62+
const srcDir = join(projectDir, 'src');
6263
const program = createProgram({
63-
rootNames: [join(projectDir, 'src', 'index.ts')],
64+
rootNames: [
65+
join(srcDir, 'index.ts'),
66+
join(srcDir, 'client.ts'),
67+
],
6468
options: {
6569
...options,
6670
emitDeclarationOnly: true,

packages/cli/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
},
1414
"./bin": {
1515
"import": "./dist/bin.js"
16+
},
17+
"./client": {
18+
"types": "./dist/client.d.ts"
1619
}
1720
},
1821
"engines": {

packages/cli/src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// support `import 'vite/client'`
2+
import 'rolldown-vite/client';

packages/global/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ if (args[0] === 'new') {
5555
});
5656
} else {
5757
// Delegate all other commands to vite-plus CLI
58+
// @ts-ignore no types for vite-plus/bin
5859
import('@voidzero-dev/vite-plus/bin');
5960
}

0 commit comments

Comments
 (0)