Skip to content

feat: add JSON schema for config - #1074

Merged
sxzz merged 8 commits into
rolldown:mainfrom
Sandbye:feat/json-schema
Oct 23, 2026
Merged

sxzz merged 8 commits into
rolldown:mainfrom
Sandbye:feat/json-schema

Conversation

@Sandbye

@Sandbye Sandbye commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

AI usage

  • No AI was used in this PR.
  • AI was used: Codex (gpt-5.6-luna High)
    • I have carefully reviewed the AI-generated content myself.

Description

Attempt at adding a generated JSON Schema for tsdown.config.json.

Generation
The schema was generated from tsdown’s UserConfig TypeScript type using the TypeScript compiler API.

It preserves:

  • Property descriptions from JSDoc
  • @default values when they are JSON-compatible literals
  • @deprecated annotations
  • Reusable $defs and $ref definitions

Function-only options, plugins, and callbacks are omitted because they cannot be represented in JSON.

The generator is currently kept separate from this PR. If preferred, it can be added to the repository later to regenerate the schema automatically.

Linked Issues

fix #679

Additional context

Verified with:

  • pnpm lint
  • pnpm typecheck
  • pnpm test run

Copilot AI lite review requested due to automatic review settings September 14, 2026 13:31
@netlify

netlify Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit a5aec1c
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/6adaf07a8dcb5e076257f502
😎 Deploy Preview https://deploy-preview-1074--tsdown-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

tsdown

pnpm add https://pkg.pr.new/rolldown/tsdown@1074 -D
npm i https://pkg.pr.new/rolldown/tsdown@1074 -D
yarn add https://pkg.pr.new/rolldown/tsdown@1074.tgz -D

create-tsdown

pnpm add https://pkg.pr.new/rolldown/tsdown/create-tsdown@1074 -D
npm i https://pkg.pr.new/rolldown/tsdown/create-tsdown@1074 -D
yarn add https://pkg.pr.new/rolldown/tsdown/create-tsdown@1074.tgz -D

@tsdown/css

pnpm add https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1074 -D
npm i https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1074 -D
yarn add https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1074.tgz -D

@tsdown/exe

pnpm add https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1074 -D
npm i https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1074 -D
yarn add https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1074.tgz -D

tsdown-migrate

pnpm add https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1074 -D
npm i https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1074 -D
yarn add https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1074.tgz -D

commit: a5aec1c

@sxzz

sxzz commented Sep 14, 2026

Copy link
Copy Markdown
Member

The JSON Schema is too large to maintain manually, so we need automated tooling to keep it up to date. Please include the generator in this PR; without it, ongoing maintenance would not be feasible.

The schema file is also quite large and would increase the npm package size. I'd prefer to keep it in the GitHub repository and let users load it via a URL, rather than include it in the published npm package.

@Sandbye

Sandbye commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Yeah, i totally agree. Will follow up on that.

@sxzz

sxzz commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Actually, I'd prefer to have the generator produce a Zod (or Zod-like) schema first, then convert it to JSON Schema. This would make the code more intuitive to maintain and the process more reliable.

This comment was marked as low quality.

@sxzz

sxzz commented Sep 14, 2026

Copy link
Copy Markdown
Member

Since Rolldown uses Valibot, I'd actually prefer Valibot over Zod here.

@Sandbye

Sandbye commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Agreed. I’ll rework the generator to produce Valibot schemas first and convert those to JSON Schema, then include the generator and generated schema in the PR. I’ll also keep the generated schema out of the npm package and serve it from the repository instead. :)

@socket-security

socket-security Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​valibot/​to-json-schema@​1.8.010010010089100

View full report

Comment thread scripts/generate-schema.ts Outdated
Comment thread scripts/schema-generator/index.ts Outdated
Comment thread package.json Outdated
Comment thread tsconfig.json Outdated
@sxzz

sxzz commented Sep 14, 2026

Copy link
Copy Markdown
Member

Also run schema:generate script in autofix.yml.

@Sandbye
Sandbye requested a review from sxzz September 15, 2026 07:08
@Sandbye

Sandbye commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Question
I found that function/API-only types are not limited to the root-level hooks and customLogger options. Nested options such as format-specific hooks/loggers, minify.mangleProps, and visitor APIs also become empty schemas ({}).

Should the JSON-specific schema omit all function/API-only options recursively, or should these remain unconstrained?

@sxzz

sxzz commented Sep 15, 2026

Copy link
Copy Markdown
Member

I'd prefer to keep these options unconstrained in the JSON Schema, including nested ones, rather than omit them.

@Sandbye

Sandbye commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

I'd prefer to keep these options unconstrained in the JSON Schema, including nested ones, rather than omit them.

Cool, then this PR is ready for final review. Nothing else from me.

@silashoeyer

Copy link
Copy Markdown

looks good to me

@sxzz

sxzz commented Sep 18, 2026

Copy link
Copy Markdown
Member

LGTM. Maybe we can also introduce a new package @tsdown/schema, providing valibot & JSON schema to AI agents.

@Sandbye

Sandbye commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

LGTM. Maybe we can also introduce a new package @tsdown/schema, providing valibot & JSON schema to AI agents.

Great! Should @tsdown/schema be a follow-up issue, or would you rather have it included in this pr?

@sxzz

sxzz commented Sep 19, 2026

Copy link
Copy Markdown
Member

I'm okay for both. It's up to you. BTW, I'm currently on vacation, and this PR will be delayed by few days.

@Sandbye

Sandbye commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

Have a nice vacation 🌴
I'll look into it when i have time next week.

@Sandbye

Sandbye commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@sxzz
I’ll leave @tsdown/schema as a follow-up so this PR stays focused on adding the JSON Schema and generator. Thanks for the suggestion!

@sxzz
sxzz enabled auto-merge (squash) October 23, 2026 05:29
@sxzz
sxzz merged commit 2410ef3 into rolldown:main Oct 23, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON Schema for tsdown.config.json

4 participants