-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add JSON schemas for the manifests generated by Vite #7960
Conversation
Looks great, thanks for making this proposal! 😃 It should make it a lot easier for plugin authors, as well as make it easier to ensure the ecosystem can follow changes to the format in the future 💯 |
Thanks for your suggestions ! |
@@ -0,0 +1,65 @@ | |||
{ | |||
"$schema": "https://json-schema.org/draft/2020-12/schema", | |||
"$id": "https://vitejs.dev/schemas/v2.0.0/manifest.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, it should be possible to retrieve the JSON schemas at this URL.
I've versioned the URL to allow for future schemas under a similar URL but I am unsure about how we want to version the schemas.
Mirroring Vite versions
This would probably add some maintenance burden if not automated. Not sure this is a good option because the schema would not necessarily change with each new Vite version.
Sync only the major version
This option would consist in keeping only the major version in sync with Vite, and minor and path version would be incremented when actual modifications are made to the schemas.
For example, schema v2.0.0
would currently be valid for Vite v2.9.6
generated manifests.
Choose later
We don't actually have to choose the versioning strategy right now.
Let's hear pros and cons or other ideas.
@@ -0,0 +1,14 @@ | |||
{ | |||
"$schema": "https://json-schema.org/draft/2020-12/schema", | |||
"$id": "https://vitejs.dev/schemas/v2.0.0/ssr-manifest.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broke my wrist so I'll get back to this in a few weeks. |
Oh, no rush... Take care! I hope you get better soon |
I've rebased this PR to make it work with the upcoming 3.0.0 version. Is is too late to change the - export type Manifest = Record<string, ManifestChunk>
+ export interface Manifest {
+ version: string,
+ chunks: Record<string, ManifestChunk>,
+ } and + export interface SSRManifest {
+ version: string,
+ chunks: Record<string, string[]>,
+ } |
I added the PR to be discussed in a future team meeting. Vite 3 could give us an opportunity to do this change. I agree that it could be better. Not only for versions, but we may want to include other information in the future. |
Co-authored-by: Máximo Mussini <maximomussini@gmail.com>
Co-authored-by: Máximo Mussini <maximomussini@gmail.com>
Co-authored-by: Máximo Mussini <maximomussini@gmail.com>
Co-authored-by: Máximo Mussini <maximomussini@gmail.com>
✅ Deploy Preview for vite-docs-main canceled.
|
@patak-dev I believe #6649 does not introduces any changes to the schema. I've removed the versions from the Edit: failing tests do not appear to be linked to this PR. |
@nhedger Since this won't be published to npm, and not served under https://vitejs.dev yet, do you have plans on how the new JSON schemas are used? You mentioned that ideally we'd serve under https://vitejs.dev/schemas/v2.0.0/schema.json for example, is this still needed? The spec shows that $id doesn't need to be a downloadable URI, so the state of the PR as is should be good too. But with that I'm curious how this file would be used in practice? |
We aren't currently publishing docs for each patch (we should though), so if we add the version in the URL, it should only use the minor. |
Good point, I actually forgot about that. Currently, the only way of accessing the schema would be through GitHub (once merged into main):
Assuming that everyone agrees, I may be able to setup a GitHub Action to automate copying the schemas to |
If we automate serving them through the public folder, we'd only be able to serve the latest JSON schema at a point of time. So if an old schema points to the URL, and returns a new different schema, would that be a problem? We could probably solve it by putting the version in the URL, and do a 301 redirect and rewrite the URLs to githubusercontent. But with all these said, I'm be curious to know if the team is fine with this. |
Description
This PR adds JSON schemas for the JSON manifests (
manifest.json
andmanifest-ssr.json
) generated by Vite.manifest.schema.json
manifest-ssr.schema.json
Both schemas use the
2020-12
draft of the JSON schema specification.Additional context
Testing the schemas
Todo
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).