Skip to content

Commit 2410ef3

Browse files
Sandbyeautofix-ci[bot]sxzz
authored
feat: add JSON schema for config (#1074)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Kevin Deng <sxzz@sxzz.moe>
1 parent c626e4a commit 2410ef3

11 files changed

Lines changed: 6507 additions & 2 deletions

File tree

‎.github/workflows/autofix.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: $PACKAGE_MANAGER install $NO_FROZEN_LOCKFILE
3737

3838
- name: Fix
39-
run: pnpm run format && pnpm run lint --fix && pnpm build --update-snapshot
39+
run: pnpm schema:generate && pnpm run format && pnpm run lint --fix && pnpm build --update-snapshot
4040

4141
- name: Commit
4242
uses: autofix-ci/action@c5b2d67aa2274e7b5a18224e8171550871fc7e4a

‎.github/workflows/src/autofix.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ jobs:
77
if: github.repository == 'rolldown/tsdown'
88
uses: sxzz/workflows/.github/workflows/autofix.yml@main
99
with:
10-
command: pnpm run format && pnpm run lint --fix && pnpm build --update-snapshot
10+
command: pnpm schema:generate && pnpm run format && pnpm run lint --fix && pnpm build --update-snapshot
1111
permissions:
1212
contents: read

‎docs/options/config-file.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ By default, `tsdown` will search for a configuration file by looking in the curr
1212

1313
Additionally, you can define your configuration directly in the `tsdown` field of your `package.json` file.
1414

15+
## JSON Schema
16+
17+
When using `tsdown.config.json`, add the schema reference to enable editor autocomplete and validation:
18+
19+
```json [tsdown.config.json]
20+
{
21+
"$schema": "https://raw.githubusercontent.com/rolldown/tsdown/main/schema.json",
22+
"entry": "src/index.ts",
23+
"format": "esm",
24+
"dts": true
25+
}
26+
```
27+
28+
The schema describes JSON-compatible configuration options. TypeScript-only values such as functions, plugins, and callbacks are available in `tsdown.config.ts` instead.
29+
1530
## Writing a Config File
1631

1732
The configuration file allows you to define and customize your build settings in a centralized and reusable way. Below is a simple example of a `tsdown` configuration file:

‎package.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
"test": "vitest",
8484
"typecheck": "tsc --noEmit",
8585
"format": "prettier --cache --write .",
86+
"schema:generate": "node ./scripts/generate-schema.ts",
87+
"schema:check": "node ./scripts/generate-schema.ts -c",
8688
"release": "node ./scripts/release.ts",
8789
"docs:dev": "pnpm -C docs run dev",
8890
"docs:build": "pnpm -C docs run build",
@@ -159,6 +161,7 @@
159161
"@types/node": "catalog:dev",
160162
"@types/picomatch": "catalog:dev",
161163
"@unocss/eslint-plugin": "catalog:docs",
164+
"@valibot/to-json-schema": "catalog:dev",
162165
"@vitejs/devtools": "catalog:peer",
163166
"@vitest/coverage-v8": "catalog:dev",
164167
"@vitest/ui": "catalog:dev",
@@ -188,6 +191,7 @@
188191
"unplugin-unused": "catalog:peer",
189192
"unplugin-vue": "catalog:dev",
190193
"unrun": "catalog:dev",
194+
"valibot": "catalog:dev",
191195
"vite": "catalog:docs",
192196
"vitest": "catalog:dev",
193197
"vue": "catalog:docs"

‎pnpm-lock.yaml‎

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ catalogs:
1818
'@sxzz/test-utils': ^0.5.20
1919
'@types/node': ^26.6.5
2020
'@types/picomatch': ^4.0.3
21+
'@valibot/to-json-schema': ^1.8.0
2122
'@vitest/coverage-v8': ^5.0.5
2223
'@vitest/ui': ^5.0.5
2324
actionspack: ^0.1.5
@@ -41,6 +42,7 @@ catalogs:
4142
unplugin-raw: ^0.8.0
4243
unplugin-vue: ^8.0.0
4344
unrun: ^0.3.1
45+
valibot: ^1.5.0
4446
vitest: ^5.0.5
4547
docs:
4648
'@iconify-json/logos': ^1.2.17

0 commit comments

Comments
 (0)