-
Notifications
You must be signed in to change notification settings - Fork 215
Avoid usage of @wordpress/components inside base components
#7996
Conversation
The @wordpress/block-editor dependency should never be us...The @wordpress/block-editor dependency should never be used on the frontend of the store due to excessive side and its dependency on @wordpress/components
woocommerce-blocks/assets/js/base/hooks/use-spacing-props.ts Lines 14 to 19 in 9be346c
🚀 This comment was generated by the automations bot based on a
|
The @wordpress/block-editor dependency should never be us...The @wordpress/block-editor dependency should never be used on the frontend of the store due to excessive side and its dependency on @wordpress/components
woocommerce-blocks/assets/js/base/hooks/use-color-props.ts Lines 18 to 21 in 9be346c
🚀 This comment was generated by the automations bot based on a
|
The @wordpress/block-editor dependency should never be us...The @wordpress/block-editor dependency should never be used on the frontend of the store due to excessive side and its dependency on @wordpress/components
woocommerce-blocks/assets/js/base/hooks/use-border-props.ts Lines 18 to 21 in 9be346c
🚀 This comment was generated by the automations bot based on a
|
|
The release ZIP for this PR is accessible via: |
Script Dependencies ReportThe
This comment was automatically generated by the |
TypeScript Errors ReportFiles with errors: 443
assets/js/atomic/blocks/product-elements/button/supports.ts
assets/js/atomic/blocks/product-elements/image/supports.ts assets/js/atomic/blocks/product-elements/rating/support.ts assets/js/atomic/blocks/product-elements/sale-badge/support.ts assets/js/atomic/blocks/product-elements/title/index.ts assets/js/base/components/drawer/index.tsx |
|
Great job @mikejolley! A heads-up that I'm working on updating I'm at the stage where all E2E tests are passing and there's one unit tests failing related to I think both PRs will contribute nicely together 🎉 |
|
Size Change: +7.1 kB (+1%) Total Size: 1.02 MB
ℹ️ View Unchanged
|
tarhi-saad
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.
Hello, @mikejolley! 👋 I left some feedback below! We should also look into this PR: #7962! There may be some conflicts!
| // @todo The @wordpress/block-editor dependency should never be used on the frontend of the store due to excessive side and its dependency on @wordpress/components | ||
| export const useSpacingProps = ( attributes: unknown ): WithStyle => { | ||
| if ( ! isFeaturePluginBuild() || ! hasSpacingStyleSupport() ) { | ||
| if ( ! isFeaturePluginBuild() ) { |
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.
I believe we should keep checking the spacing style support (i.e., ! hasSpacingStyleSupport()), even if we still need to find a way to avoid using the @wordpress/block-editor dependency!
| if ( ! isFeaturePluginBuild() ) { | |
| if ( ! isFeaturePluginBuild() || ! hasSpacingStyleSupport() ) { |
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.
All this does is check for __experimentalGetSpacingClassesAndStyles, and whats more, including an empty style prop should not have negative consequences even if included right?
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.
@mikejolley, I believe this check was added to fix crash on WP 5.8
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.
Thats ok then, we have a minimum version check in place for WP 6.1.
|
The release ZIP for this PR is accessible via: Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
assets/js/atomic/blocks/product-elements/button/supports.ts
assets/js/atomic/blocks/product-elements/image/supports.ts assets/js/atomic/blocks/product-elements/rating/support.ts assets/js/atomic/blocks/product-elements/sale-badge/support.ts assets/js/atomic/blocks/product-elements/title/index.ts assets/js/base/components/drawer/index.tsx |
|
blocked until a decision is reached on pdToLP-fF-p2#comment-170 |
|
This PR has been marked as If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label. |
@mikejolley, @ralucaStan, I think we should progress with this PR. I'm removing "blocked" label 🙌 |
|
@kmanijak thank you, feel free to also add your review |
kmanijak
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.
Thanks @mikejolley for taking care of this! 🎉
I tested Mini Cart which seems to be the only block using Drawer at it looks good.
I left two minor comments 🙌
0b20fca to
f9e11f2
Compare
tarhi-saad
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.
Thank you for the changes, @mikejolley! I tested it again. Everything looks good! So, let's 🚢 it! 🙌
…block-editor external
This reverts commit ce95800.
Co-authored-by: Saad Tarhi <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
Co-authored-by: kmanijak <[email protected]>
cd956ca to
c5b76dd
Compare
I spent some time investigating the usage of
@wordpress/componentsin ourbasedirectory and fixed the violations I found.Modalcomponent was being imported from@wordpress/components. I swapped this towordpress-components@wordpress/block-editorwithin theutilsdirectory. To avoid polluting that import, I moved thehasSpacingStyleSupportfunction check inline where used. This prevents a@wordpress/block-editordependency wheneverutilsare used.typeprefixes within the@wordpress/typesdirectory.baseas a reminder that@wordpress/componentsshould not be used directly within this directory.There were three violations I am unable to fix, so I have added todos. The following hooks all have a
@wordpress/block-editordependency, and by extension, a dependency on@wordpress/components.useBorderPropsuseColorPropsuseSpacingPropsThese hooks might need to be refactored to create styles based on props internally instead of relying on the experimental hooks from
@wordpress/block-editorbecause I don't believe they are suitable for the frontend of the store. Or I guess they could be used in editor context only, and the styles saved to the HTML somehow.cc @woocommerce/woo-fse
Closes #5611
Testing
Confirm successful build and test suite passes.