Skip to content
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

fix: remove circular reference to usePaneRouter #6664

Merged
merged 1 commit into from
May 17, 2024
Merged

Conversation

stipsan
Copy link
Member

@stipsan stipsan commented May 14, 2024

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

@stipsan stipsan requested a review from a team as a code owner May 14, 2024 20:58
@stipsan stipsan requested review from juice49 and removed request for a team May 14, 2024 20:58
Copy link

vercel bot commented May 14, 2024

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) Visit Preview May 16, 2024 9:49am

Copy link
Contributor

No changes to documentation

@stipsan stipsan enabled auto-merge May 14, 2024 20:59
Copy link
Contributor

github-actions bot commented May 14, 2024

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
Copy link
Contributor

binoy14 commented May 15, 2024

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

Copy link
Contributor

@juice49 juice49 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Cody!

@stipsan stipsan added this pull request to the merge queue May 17, 2024
Merged via the queue into next with commit d66def2 May 17, 2024
37 of 38 checks passed
@stipsan stipsan deleted the fix-circular-reference branch May 17, 2024 08:34
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.

None yet

3 participants