Skip to content

Commit 07358e4

Browse files
committed
feat(create-vite): pass -b to tsc so that vite.config.ts is checked
Currently when running "pnpm run build" on a fresh Vite project using any of these templates, tsc doesn't fail when there are type errors in vite.config.ts, such as something obvious like: const foo: string = 123; Passing -b makes it run for all project references, meaning that vite.config.ts starts to be type checked too during build. In order to not generate a vite.config.js and vite.config.d.ts we need to make the main tsconfig.json have nothing but references to tsconfig.node.json and a new tsconfig.app.json, as is done in the create-vue project, see: https://github.com/vuejs/create-vue/blob/f75fd9813a624b8e44b012608335721901aba00b/template/tsconfig/base/tsconfig.json
1 parent 42fd11c commit 07358e4

21 files changed

+192
-127
lines changed

packages/create-vite/template-preact-ts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "tsc && vite build",
8+
"build": "tsc -b && vite build",
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5+
"target": "ES2020",
6+
"useDefineForClassFields": true,
7+
"module": "ESNext",
8+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
9+
"skipLibCheck": true,
10+
"paths": {
11+
"react": ["./node_modules/preact/compat/"],
12+
"react-dom": ["./node_modules/preact/compat/"]
13+
},
14+
15+
/* Bundler mode */
16+
"moduleResolution": "bundler",
17+
"allowImportingTsExtensions": true,
18+
"resolveJsonModule": true,
19+
"isolatedModules": true,
20+
"noEmit": true,
21+
"jsx": "react-jsx",
22+
"jsxImportSource": "preact",
23+
24+
/* Linting */
25+
"strict": true,
26+
"noUnusedLocals": true,
27+
"noUnusedParameters": true,
28+
"noFallthroughCasesInSwitch": true
29+
},
30+
"include": ["src"]
31+
}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
{
2-
"compilerOptions": {
3-
"target": "ES2020",
4-
"useDefineForClassFields": true,
5-
"module": "ESNext",
6-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7-
"skipLibCheck": true,
8-
"paths": {
9-
"react": ["./node_modules/preact/compat/"],
10-
"react-dom": ["./node_modules/preact/compat/"]
2+
"files": [],
3+
"references": [
4+
{
5+
"path": "./tsconfig.app.json"
116
},
12-
13-
/* Bundler mode */
14-
"moduleResolution": "bundler",
15-
"allowImportingTsExtensions": true,
16-
"resolveJsonModule": true,
17-
"isolatedModules": true,
18-
"noEmit": true,
19-
"jsx": "react-jsx",
20-
"jsxImportSource": "preact",
21-
22-
/* Linting */
23-
"strict": true,
24-
"noUnusedLocals": true,
25-
"noUnusedParameters": true,
26-
"noFallthroughCasesInSwitch": true
27-
},
28-
"include": ["src"],
29-
"references": [{ "path": "./tsconfig.node.json" }]
7+
{
8+
"path": "./tsconfig.node.json"
9+
}
10+
]
3011
}

packages/create-vite/template-preact-ts/tsconfig.node.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
45
"skipLibCheck": true,
56
"module": "ESNext",
67
"moduleResolution": "bundler",

packages/create-vite/template-qwik-ts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "tsc && vite build",
8+
"build": "tsc -b && vite build",
99
"preview": "serve dist"
1010
},
1111
"devDependencies": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5+
"target": "ES2020",
6+
"useDefineForClassFields": true,
7+
"module": "ESNext",
8+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
9+
"skipLibCheck": true,
10+
11+
/* Bundler mode */
12+
"moduleResolution": "bundler",
13+
"allowImportingTsExtensions": true,
14+
"resolveJsonModule": true,
15+
"isolatedModules": true,
16+
"noEmit": true,
17+
"jsx": "react-jsx",
18+
"jsxImportSource": "@builder.io/qwik",
19+
20+
/* Linting */
21+
"strict": true,
22+
"noUnusedLocals": true,
23+
"noUnusedParameters": true,
24+
"noFallthroughCasesInSwitch": true
25+
},
26+
"include": ["src"]
27+
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
{
2-
"compilerOptions": {
3-
"target": "ES2020",
4-
"useDefineForClassFields": true,
5-
"module": "ESNext",
6-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7-
"skipLibCheck": true,
8-
9-
/* Bundler mode */
10-
"moduleResolution": "bundler",
11-
"allowImportingTsExtensions": true,
12-
"resolveJsonModule": true,
13-
"isolatedModules": true,
14-
"noEmit": true,
15-
"jsx": "react-jsx",
16-
"jsxImportSource": "@builder.io/qwik",
17-
18-
/* Linting */
19-
"strict": true,
20-
"noUnusedLocals": true,
21-
"noUnusedParameters": true,
22-
"noFallthroughCasesInSwitch": true
23-
},
24-
"include": ["src"],
25-
"references": [{ "path": "./tsconfig.node.json" }]
2+
"files": [],
3+
"references": [
4+
{
5+
"path": "./tsconfig.app.json"
6+
},
7+
{
8+
"path": "./tsconfig.node.json"
9+
}
10+
]
2611
}

packages/create-vite/template-qwik-ts/tsconfig.node.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
45
"skipLibCheck": true,
56
"module": "ESNext",
67
"moduleResolution": "bundler",

packages/create-vite/template-react-ts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "tsc && vite build",
8+
"build": "tsc -b && vite build",
99
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1010
"preview": "vite preview"
1111
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5+
"target": "ES2020",
6+
"useDefineForClassFields": true,
7+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
8+
"module": "ESNext",
9+
"skipLibCheck": true,
10+
11+
/* Bundler mode */
12+
"moduleResolution": "bundler",
13+
"allowImportingTsExtensions": true,
14+
"resolveJsonModule": true,
15+
"isolatedModules": true,
16+
"noEmit": true,
17+
"jsx": "react-jsx",
18+
19+
/* Linting */
20+
"strict": true,
21+
"noUnusedLocals": true,
22+
"noUnusedParameters": true,
23+
"noFallthroughCasesInSwitch": true
24+
},
25+
"include": ["src"]
26+
}
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
{
2-
"compilerOptions": {
3-
"target": "ES2020",
4-
"useDefineForClassFields": true,
5-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6-
"module": "ESNext",
7-
"skipLibCheck": true,
8-
9-
/* Bundler mode */
10-
"moduleResolution": "bundler",
11-
"allowImportingTsExtensions": true,
12-
"resolveJsonModule": true,
13-
"isolatedModules": true,
14-
"noEmit": true,
15-
"jsx": "react-jsx",
16-
17-
/* Linting */
18-
"strict": true,
19-
"noUnusedLocals": true,
20-
"noUnusedParameters": true,
21-
"noFallthroughCasesInSwitch": true
22-
},
23-
"include": ["src"],
24-
"references": [{ "path": "./tsconfig.node.json" }]
2+
"files": [],
3+
"references": [
4+
{
5+
"path": "./tsconfig.app.json"
6+
},
7+
{
8+
"path": "./tsconfig.node.json"
9+
}
10+
]
2511
}

packages/create-vite/template-react-ts/tsconfig.node.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
45
"skipLibCheck": true,
56
"module": "ESNext",
67
"moduleResolution": "bundler",

packages/create-vite/template-solid-ts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "tsc && vite build",
8+
"build": "tsc -b && vite build",
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5+
"target": "ES2020",
6+
"useDefineForClassFields": true,
7+
"module": "ESNext",
8+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
9+
"skipLibCheck": true,
10+
11+
/* Bundler mode */
12+
"moduleResolution": "bundler",
13+
"allowImportingTsExtensions": true,
14+
"resolveJsonModule": true,
15+
"isolatedModules": true,
16+
"noEmit": true,
17+
"jsx": "preserve",
18+
"jsxImportSource": "solid-js",
19+
20+
/* Linting */
21+
"strict": true,
22+
"noUnusedLocals": true,
23+
"noUnusedParameters": true,
24+
"noFallthroughCasesInSwitch": true
25+
},
26+
"include": ["src"]
27+
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
{
2-
"compilerOptions": {
3-
"target": "ES2020",
4-
"useDefineForClassFields": true,
5-
"module": "ESNext",
6-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7-
"skipLibCheck": true,
8-
9-
/* Bundler mode */
10-
"moduleResolution": "bundler",
11-
"allowImportingTsExtensions": true,
12-
"resolveJsonModule": true,
13-
"isolatedModules": true,
14-
"noEmit": true,
15-
"jsx": "preserve",
16-
"jsxImportSource": "solid-js",
17-
18-
/* Linting */
19-
"strict": true,
20-
"noUnusedLocals": true,
21-
"noUnusedParameters": true,
22-
"noFallthroughCasesInSwitch": true
23-
},
24-
"include": ["src"],
25-
"references": [{ "path": "./tsconfig.node.json" }]
2+
"files": [],
3+
"references": [
4+
{
5+
"path": "./tsconfig.app.json"
6+
},
7+
{
8+
"path": "./tsconfig.node.json"
9+
}
10+
]
2611
}

packages/create-vite/template-solid-ts/tsconfig.node.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
45
"skipLibCheck": true,
56
"module": "ESNext",
67
"moduleResolution": "bundler",

packages/create-vite/template-svelte-ts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "vite",
88
"build": "vite build",
99
"preview": "vite preview",
10-
"check": "svelte-check --tsconfig ./tsconfig.json"
10+
"check": "svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json"
1111
},
1212
"devDependencies": {
1313
"@sveltejs/vite-plugin-svelte": "^3.0.2",

packages/create-vite/template-vue-ts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "vue-tsc && vite build",
8+
"build": "vue-tsc -b && vite build",
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5+
"target": "ES2020",
6+
"useDefineForClassFields": true,
7+
"module": "ESNext",
8+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
9+
"skipLibCheck": true,
10+
11+
/* Bundler mode */
12+
"moduleResolution": "bundler",
13+
"allowImportingTsExtensions": true,
14+
"resolveJsonModule": true,
15+
"isolatedModules": true,
16+
"noEmit": true,
17+
"jsx": "preserve",
18+
19+
/* Linting */
20+
"strict": true,
21+
"noUnusedLocals": true,
22+
"noUnusedParameters": true,
23+
"noFallthroughCasesInSwitch": true
24+
},
25+
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
26+
}

0 commit comments

Comments
 (0)