Skip to content

Conversation

@Gianthard-cyh
Copy link
Contributor

Description

Introduce valibot to rpc interface, for better type generation and API verification.

Linked Issues

#9

Introduce valibot to rpc interface, for better type generation and API verification.

Additional context

@Gianthard-cyh Gianthard-cyh changed the title feat(rpc): feat(rpc): valibot verification for rpc Jan 11, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 11, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@vitejs/devtools@161
npm i https://pkg.pr.new/@vitejs/devtools-kit@161
npm i https://pkg.pr.new/@vitejs/devtools-rpc@161
npm i https://pkg.pr.new/@vitejs/devtools-vite@161

commit: f898497

@Gianthard-cyh Gianthard-cyh mentioned this pull request Jan 11, 2026
41 tasks
@Gianthard-cyh
Copy link
Contributor Author

I think this is mostly done. Before adding some tests, I wanted to check whether I’m heading in the right direction.

Since the definitions of RPC methods are scattered across multiple packages (devtools-vite and devtools-core), it seemed reasonable to me to colocate the schemas with the RPC function definitions. In the current implementation, I modified defineRpcFunction to accept argument and return schemas as options. These schemas are then collected and exported from devtools-vite and devtools-core, and devtools-kit imports them for runtime validation.

This approach, however, introduces some additional exports and also creates cyclic dependencies. As a result, vite ends up being pulled in as a dependency of devtools-vite, and lightningcss (a dependency of Vite) breaks when being bundled, since it is not supposed to be bundled. This seems to be related to Vite listing it as a regular dependency rather than a devDependency (see parcel-bundler/lightningcss#701).

I worked around this by marking lightningcss as external, which makes the bundle work again, but I’m not sure whether this aligns with the intended design.

To avoid the cyclic dependency, it looks like one option would be to move all schemas into devtools-kit, but that would separate the RPC function definitions from their schemas. That would mean adding or updating a method would require changes in two places, which feels a bit error-prone.

I might be missing something here, so I’d really appreciate some guidance on the intended architecture. In particular, I’d love to understand where you expect the schemas to live and how the dependency direction between devtools-vite, devtools-core, and devtools-kit is meant to be structured.

@antfu

@Gianthard-cyh Gianthard-cyh changed the title feat(rpc): valibot verification for rpc feat(rpc): runtime type verification for rpc calls Jan 14, 2026
@Gianthard-cyh Gianthard-cyh changed the title feat(rpc): runtime type verification for rpc calls feat(rpc): runtime type validation for rpc calls Jan 14, 2026
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.

1 participant