-
Notifications
You must be signed in to change notification settings - Fork 499
feat(cli): add command for visualizing schema bloat #11224
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
🧪 E2E Preview environment🔑 Environment Variables for Local TestingThis is the preview URL for the E2E tests: https://e2e-studio-p2oyipfer.sanity.dev To run the E2E tests locally, you can use the following environment variables, then run 💬 Remember to build the project first with |
📊 Playwright Test ReportThis report contains test results, including videos of failing tests. |
⚡️ Editor Performance ReportUpdated Thu, 27 Nov 2025 17:43:42 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
2dededf to
2c36abb
Compare
Coverage Report
File CoverageNo changed files found. |
2c36abb to
19f4022
Compare
19f4022 to
7e30900
Compare
7e30900 to
b7b96cd
Compare
stipsan
left a comment
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.
Fascinating! I think for a guide it would be helpful to show a before/after to demonstrate the impact of refactoring a schema from using inline types to named types, to better understand what to look for in the esbuild visualizer graphs.
I've triggered a preview release so I can try it on some test studios.
Is there a measurable runtime difference in how long prepareConfig spends processing the schema as well? We have to resolve it up front before the studio can load, and it's resolved again during hot reload cycles if the schema is edited in any way 🤔
b7b96cd to
c121f06
Compare
|
@stipsan: Nice, nice! I fixed a build error, but now it seems like the publishing failed. I can wait with merging this until you've tested it.
Not sure if I follow you. This doesn't change anything related to |
Hmmm seems like pkg.pr.new isn't working atm, so we can just merge to
I understand that this PR in itself doesn't affect sanity/packages/sanity/src/core/config/prepareConfig.tsx Lines 214 to 231 in ae1394c
|
|
Ah, yes! It's true that interpreting this number can be a bit tricky. It's now only for the "new" server-side schema approach (which even used by anything proper yet). A smaller schema from this file doesn't necessarily mean that |
This adds a command `sanity schema validate --debug-metafile-path <path>` which writes a file with information about the size of the serialized schema which follows ESBuild's metafile format. This can then be analyzed through https://esbuild.github.io/analyze/
c121f06 to
d114d13
Compare
Preview this PR with pkg.pr.newCreate a new projectnpx https://pkg.pr.new/create-sanity@23db03fNote: This installs the latest Sanity Studio from the npm registry. To apply the changes from this PR in your newly created project, run the install commands below for each package listed in your package.json ...Or run the Sanity CLI...Or upgrade project dependencies
|
|
@stipsan: I've now rebased from latest |
stipsan
left a comment
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.
Let's go!

Description
Due to the dynamic nature of
sanity.config.tsit's very easy to create enormous schemas without really being aware of this. A common gotcha is to inline types/fields instead of defining a named type.This adds a command
sanity schema validate --debug-metafile-path <path>which writes a file with information about the size of the serialized schema which follows ESBuild's metafile format. This can then be analyzed through https://esbuild.github.io/analyze/.Here are some screenshots on
dev/test-studio's schema:I've added this to the
sanity schema validatecommand since it seems to be quite similar: It's about analyzing the schema to help the developer understand potential problems.What to review
Testing
dev/test-studioNotes for release
sanity schema validate --debug-metafile-path <path>is now available. I think we should have a separate guide for how to explore the schema bloat before this gets merged.