Skip to content

Commit 2b8ce76

Browse files
committed
Split jsconfigs by environment
1 parent 6105422 commit 2b8ce76

File tree

8 files changed

+88
-26
lines changed

8 files changed

+88
-26
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node-version: [18.x, 20.x, 22.x]
14+
node-version: [20.x, 22.x, 24.x]
1515

1616
steps:
1717
- uses: actions/checkout@v4
@@ -30,6 +30,9 @@ jobs:
3030
- name: Run Svelte check
3131
run: npm run check
3232

33+
- name: Run tsc check
34+
run: npm run tsc
35+
3336
- name: Build
3437
run: npm run build
3538

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ This template is derived from [the official template](https://github.com/sveltej
77
Some notable customizations are:
88

99
0. `package-lock.json` is NOT committed on purpose
10-
1. Vite 6.0 and Vitest 3.0 is included
11-
2. The included adapter is changed from `auto` to `@sveltejs/adapter-node`, assuming that you are not targeting [any specific deployment target](https://svelte.dev/docs/kit/adapter-auto).
10+
1. The included adapter is changed from `auto` to `@sveltejs/adapter-node`, assuming that you are not targeting [any specific deployment target](https://svelte.dev/docs/kit/adapter-auto).
11+
2. Split tsconfig of web/test/node environments via cascading `jsconfig.*.json` to avoid lib pollution.
1212

1313
## Instructions
1414

jsconfig.app.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"extends": "./jsconfig.base.json",
3+
"compilerOptions": {
4+
"sourceMap": true,
5+
"tsBuildInfoFile": "node_modules/.tmp/app.tsbuildinfo"
6+
},
7+
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
8+
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
9+
//
10+
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
11+
// from the referenced tsconfig.json - TypeScript does not merge them in
12+
"exclude": [
13+
// copied from .svelte-kit/tsconfig.json
14+
"./node_modules/**",
15+
"./src/service-worker.js",
16+
"./src/service-worker/**/*.js",
17+
"./src/service-worker.ts",
18+
"./src/service-worker/**/*.ts",
19+
"./src/service-worker.d.ts",
20+
"./src/service-worker/**/*.d.ts",
21+
// exclude tests
22+
"./src/**/*.spec.js",
23+
"./src/**/*.spec.ts",
24+
"./src/**/*.test.js",
25+
"./src/**/*.test.ts"
26+
]
27+
}

jsconfig.base.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "./.svelte-kit/tsconfig.json",
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"checkJs": true,
6+
"esModuleInterop": true,
7+
"forceConsistentCasingInFileNames": true,
8+
"resolveJsonModule": true,
9+
"skipLibCheck": true,
10+
"sourceMap": false,
11+
"strict": true,
12+
"moduleResolution": "bundler",
13+
"composite": true
14+
}
15+
}

jsconfig.json

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
{
22
"extends": "./.svelte-kit/tsconfig.json",
3-
"compilerOptions": {
4-
"allowJs": true,
5-
"checkJs": true,
6-
"esModuleInterop": true,
7-
"forceConsistentCasingInFileNames": true,
8-
"resolveJsonModule": true,
9-
"skipLibCheck": true,
10-
"sourceMap": true,
11-
"strict": true,
12-
"moduleResolution": "bundler"
13-
}
14-
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
15-
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
16-
//
17-
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
18-
// from the referenced tsconfig.json - TypeScript does not merge them in
3+
"references": [
4+
{ "path": "./jsconfig.app.json" },
5+
{ "path": "./jsconfig.vitest.json" },
6+
{ "path": "./jsconfig.node.json" }
7+
],
8+
// ensure it a dummy config
9+
"include": [],
10+
"exclude": [],
11+
"files": []
1912
}

jsconfig.node.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./jsconfig.base.json",
3+
"compilerOptions": {
4+
"tsBuildInfoFile": "node_modules/.tmp/node.tsbuildinfo",
5+
"lib": ["esnext"]
6+
},
7+
"include": [
8+
"./vite.config.js"
9+
]
10+
}

jsconfig.vitest.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./jsconfig.base.json",
3+
"compilerOptions": {
4+
"tsBuildInfoFile": "node_modules/.tmp/vitest.tsbuildinfo"
5+
},
6+
"include": [
7+
"./src/**/*.spec.js",
8+
"./src/**/*.spec.ts",
9+
"./src/**/*.test.js",
10+
"./src/**/*.test.ts"
11+
]
12+
}

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@qbane/sveltekit-template",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "My opinionated SvelteKit template in pure JavaScript.",
55
"author": "qbane",
66
"type": "module",
@@ -9,22 +9,24 @@
99
"dev": "vite dev",
1010
"build": "vite build",
1111
"preview": "vite preview",
12-
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
12+
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.app.json",
13+
"tsc": "tsc -b jsconfig.json",
1314
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
1415
"test:unit": "vitest",
1516
"test": "npm run test:unit -- --run"
1617
},
1718
"devDependencies": {
1819
"@sveltejs/adapter-node": "^5.2.12",
19-
"@sveltejs/kit": "^2.21.4",
20+
"@sveltejs/kit": "^2.22.2",
2021
"@sveltejs/vite-plugin-svelte": "^5.1.0",
21-
"svelte": "^5.34.1",
22-
"svelte-check": "^4.2.1",
22+
"@types/node": "^22.15.34",
23+
"svelte": "^5.34.9",
24+
"svelte-check": "^4.2.2",
2325
"typescript": "^5.8.3",
2426
"vite": "^6.3.5",
25-
"vitest": "^3.2.3"
27+
"vitest": "^3.2.4"
2628
},
2729
"engines": {
28-
"node": ">=18.0.0 <23.0.0"
30+
"node": ">=20.0.0 <25.0.0"
2931
}
3032
}

0 commit comments

Comments
 (0)