sanity-io / sanity

Sanity Studio – Rapidly configure content workspaces powered by structured content
https://www.sanity.io
MIT License
4.96k stars 390 forks source link

fix: remove circular reference to `usePaneRouter` #6664

Closed stipsan closed 2 weeks ago

stipsan commented 2 weeks ago

Description

When running sanity build this annoying warning happens:

✔ Clean output folder (3ms)
Export "P" of module "node_modules/sanity/lib/_chunks-es/StructureToolProvider.mjs" was reexported through module "node_modules/sanity/lib/structure.mjs" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
Either change the import in "node_modules/@sanity/presentation/dist/_chunks-es/PresentationTool.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.
Export "S" of module "node_modules/sanity/lib/_chunks-es/StructureToolProvider.mjs" was reexported through module "node_modules/sanity/lib/structure.mjs" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
Either change the import in "node_modules/@sanity/presentation/dist/_chunks-es/PresentationTool.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.
Export "g" of module "node_modules/sanity/lib/_chunks-es/StructureToolProvider.mjs" was reexported through module "node_modules/sanity/lib/structure.mjs" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
Either change the import in "node_modules/@sanity/presentation/dist/_chunks-es/PresentationTool.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.
Export "h" of module "node_modules/sanity/lib/_chunks-es/StructureToolProvider.mjs" was reexported through module "node_modules/sanity/lib/structure.mjs" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
Either change the import in "node_modules/@sanity/presentation/dist/_chunks-es/PresentationTool.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.
Export "R" of module "node_modules/sanity/lib/_chunks-es/StructureToolProvider.mjs" was reexported through module "node_modules/sanity/lib/structure.mjs" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
Either change the import in "node_modules/@sanity/presentation/dist/_chunks-es/BroadcastDisplayedDocument.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.
✔ Build Sanity Studio (10895ms)

Turns out the root cause is that inside node_modules/sanity/lib/_chunks-es/StructureToolProvider.mjs there's this import:

import {usePaneRouter} from 'sanity/structure'

That's a problem, because sanity/lib/structure.mjs is re-exporting from ./_chunks-es/StructureToolProvider.mjs. This PR solves it by changing the import to the same relative imports used by other components that use usePaneRouter.

What to review

If it builds it works, moving forward we should be careful not to introduce new circular references. git blame shows that this circular import were added less than a month ago.

Testing

Existing tests are sufficient

Notes for release

Fixes a circular import inside sanity/structure for usePaneRouter

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2024 9:49am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2024 9:49am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2024 9:49am
1 Ignored Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **studio-workshop** | ⬜️ Ignored ([Inspect](https://vercel.com/sanity-io/studio-workshop/GCjx6cvSc3sKdaDtNVUtiaB2dD2W)) | [Visit Preview](https://studio-workshop-git-fix-circular-reference.sanity.build) | | May 16, 2024 9:49am |
github-actions[bot] commented 2 weeks ago

No changes to documentation

github-actions[bot] commented 2 weeks ago

Component Testing Report Updated May 16, 2024 9:55 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 34s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 7s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 31s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 17s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 4s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 20s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 31s 12 0 0
binoy14 commented 2 weeks ago

Great catch cody, thanks! I will see if we can add an eslint to complain about this so you can't import sanity/structure inside structure