Mobile App: Avoid code references that create cyclic dependencies #27751
Labels
Mobile App - i.e. Android or iOS
Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Needs Dev
Ready for, and needs developer efforts
[Type] Code Quality
Issues or PRs that relate to code quality
Originally reported by @rafaelgalani when working on #27414 - refactoring to replace the store name wth the exposed store definition for
@wordpress/edit-post
package. The related part of the comment:There are some architectural issues in React Native files that this PR uncovers. The packages should depend on each other in the following direction:
edit-post
block-library
editor
blocks
components
element
There is also some mix in the picture as
edit-post
itself might be using one of the deeper dependencies directly, and so on.We left hardcoded strings outside of the
@wordpress/edit-post
package and plan to fix all of the issues separately. There are other high-level packages:edit-site
,edit-widgets
, oredit-navigation
that shouldn't be referenced in other parts of Gutenberg core as well.Since
@wordpress/edit-post
is an entry point, it should never be the dependency of other core components (it's a different story for 3rd party plugins that customize UI). I'm aware it's a bit of gray area for stores as they are usually consumed inside components so basically it works. There is this issue though that codebase is tightly coupled to the specific screen - edit post. As soon as you will want to support other screens for things like a site, theme templates, or maybe post comments, it will become a blocker. We don't have a solid solution for that, so far we were using props or editor settings for passing down information where necessary. It feels like we need some sort of scope detection to make it more robust. If you have some ideas, I'm happy to hear your thoughts.Packages to fix
You can search for
core/edit-post
string in the following packages to discover those issues:@wordpress/components
@wordpress/block-directory
@wordpress/block-library
@wordpress/editor
All those packages should find a different way to obtain data from
@wordpress/edit-post
. /cc @Tug @hypestThe text was updated successfully, but these errors were encountered: