Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Document and update naming of Block Asset Handles #4324

Merged
merged 8 commits into from Jun 9, 2021

Conversation

mikejolley
Copy link
Member

@mikejolley mikejolley commented Jun 8, 2021

This PR establishes the pattern of naming block handles as wc-{blockname}-block, and other scripts as wc-blocks-{script} to avoid conflicts.

To help map handles -> built scripts I've also made script filenames match. I did not do this for the blocks themselves because it caused some breakage in Atomic Blocks and complicates how blocks are setup in webpack.

Closes #2660

How to test the changes in this Pull Request:

  • Tests should pass
  • Check existing block types still show up in the editor and can be inserted without regression.
  • Console should be error-free
  • Specifically test single-product block works to verify Atomic Blocks are not broken

Dev Note

Some script handles have been changed in this version for consistency. It is unlikely that these handles are being used directly by 3rd parties because they are only used within the blocks, however for reference:

  • wc-block-vendors-style -> wc-blocks-vendors-style
  • wc-block-editor -> wc-blocks-editor-style
  • wc-block-style -> wc-blocks-style
  • wc-vendors -> wc-blocks-vendors
  • wc-shared-context -> wc-blocks-shared-context
  • wc-shared-hocs -> wc-blocks-shared-hocs

In addition, all block script handles now have the -block suffix.

Changelog

Made script and style handles consistent.

@mikejolley mikejolley self-assigned this Jun 8, 2021
@mikejolley mikejolley requested a review from a team as a code owner June 8, 2021 15:18
@mikejolley mikejolley requested review from Aljullu and removed request for a team June 8, 2021 15:18
@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2021

Size Change: +21 B (0%)

Total Size: 988 kB

Filename Size Change
build/all-products-frontend.js 34.8 kB +3 B (0%)
build/all-products.js 36.5 kB +1 B (0%)
build/blocks.js 0 B -3.51 kB (removed) 🏆
build/cart.js 44.4 kB +1 B (0%)
build/checkout.js 46.6 kB -1 B (0%)
build/editor-rtl.css 0 B -14.9 kB (removed) 🏆
build/editor.css 0 B -14.9 kB (removed) 🏆
build/product-top-rated.js 6.26 kB +1 B (0%)
build/single-product-frontend.js 38.1 kB +3 B (0%)
build/style-rtl.css 0 B -19 kB (removed) 🏆
build/style.css 0 B -18.9 kB (removed) 🏆
build/vendors-style-rtl.css 0 B -1.05 kB (removed) 🏆
build/vendors-style.css 0 B -1.05 kB (removed) 🏆
build/vendors.js 0 B -242 kB (removed) 🏆
build/wc-shared-context.js 0 B -1.54 kB (removed) 🏆
build/wc-shared-hocs.js 0 B -1.73 kB (removed) 🏆
build/wc-blocks-editor-style-rtl.css 14.9 kB +14.9 kB (new file) 🆕
build/wc-blocks-editor-style.css 14.9 kB +14.9 kB (new file) 🆕
build/wc-blocks-shared-context.js 1.54 kB +1.54 kB (new file) 🆕
build/wc-blocks-shared-hocs.js 1.74 kB +1.74 kB (new file) 🆕
build/wc-blocks-style-rtl.css 19 kB +19 kB (new file) 🆕
build/wc-blocks-style.css 18.9 kB +18.9 kB (new file) 🆕
build/wc-blocks-vendors-style-rtl.css 1.05 kB +1.05 kB (new file) 🆕
build/wc-blocks-vendors-style.css 1.05 kB +1.05 kB (new file) 🆕
build/wc-blocks-vendors.js 242 kB +242 kB (new file) 🆕
build/wc-blocks.js 3.51 kB +3.51 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
build/active-filters-frontend.js 7.98 kB 0 B
build/active-filters.js 7.53 kB 0 B
build/all-reviews.js 9.29 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.39 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 2 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 334 B 0 B
build/atomic-block-components/add-to-cart-frontend.js 8.75 kB 0 B
build/atomic-block-components/add-to-cart.js 7.81 kB 0 B
build/atomic-block-components/button-frontend.js 1.73 kB 0 B
build/atomic-block-components/button.js 844 B 0 B
build/atomic-block-components/category-list-frontend.js 469 B 0 B
build/atomic-block-components/category-list.js 478 B 0 B
build/atomic-block-components/image-frontend.js 1.66 kB 0 B
build/atomic-block-components/image.js 1.3 kB 0 B
build/atomic-block-components/price-frontend.js 1.98 kB 0 B
build/atomic-block-components/price.js 2.01 kB 0 B
build/atomic-block-components/rating-frontend.js 521 B 0 B
build/atomic-block-components/rating.js 525 B 0 B
build/atomic-block-components/sale-badge-frontend.js 469 B 0 B
build/atomic-block-components/sale-badge.js 475 B 0 B
build/atomic-block-components/sku-frontend.js 389 B 0 B
build/atomic-block-components/sku.js 393 B 0 B
build/atomic-block-components/stock-indicator-frontend.js 569 B 0 B
build/atomic-block-components/stock-indicator.js 572 B 0 B
build/atomic-block-components/summary-frontend.js 906 B 0 B
build/atomic-block-components/summary.js 910 B 0 B
build/atomic-block-components/tag-list-frontend.js 464 B 0 B
build/atomic-block-components/tag-list.js 472 B 0 B
build/atomic-block-components/title-frontend.js 1.41 kB 0 B
build/atomic-block-components/title.js 1.26 kB 0 B
build/attribute-filter-frontend.js 17.7 kB 0 B
build/attribute-filter.js 11.4 kB 0 B
build/blocks-checkout-editor.js 10.5 kB 0 B
build/blocks-checkout.js 19.9 kB 0 B
build/cart-frontend.js 77.9 kB 0 B
build/checkout-frontend.js 81.9 kB 0 B
build/featured-category.js 7.23 kB 0 B
build/featured-product.js 9.4 kB 0 B
build/handpicked-products.js 5.89 kB 0 B
build/price-filter-frontend.js 14.3 kB 0 B
build/price-filter.js 9.3 kB 0 B
build/price-format.js 1.38 kB 0 B
build/product-best-sellers.js 6.12 kB 0 B
build/product-categories.js 3.38 kB 0 B
build/product-category.js 6.99 kB 0 B
build/product-new.js 6.28 kB 0 B
build/product-on-sale.js 6.62 kB 0 B
build/product-search.js 2.68 kB 0 B
build/product-tag.js 6.11 kB 0 B
build/products-by-attribute.js 7.22 kB 0 B
build/reviews-by-category.js 11.2 kB 0 B
build/reviews-by-product.js 12.7 kB 0 B
build/reviews-frontend.js 8.94 kB 0 B
build/single-product.js 9.65 kB 0 B
build/vendors--atomic-block-components/price-frontend.js 6.54 kB 0 B
build/wc-blocks-data.js 10.9 kB 0 B
build/wc-blocks-google-analytics.js 1.99 kB 0 B
build/wc-blocks-middleware.js 1.48 kB 0 B
build/wc-blocks-registry.js 2.75 kB 0 B
build/wc-payment-method-bacs.js 812 B 0 B
build/wc-payment-method-cheque.js 807 B 0 B
build/wc-payment-method-cod.js 903 B 0 B
build/wc-payment-method-paypal.js 844 B 0 B
build/wc-payment-method-stripe.js 12.4 kB 0 B
build/wc-settings.js 2.94 kB 0 B

compressed-size-action

@mikejolley mikejolley added skip-changelog PRs that you don't want to appear in the changelog. and removed status: needs review labels Jun 8, 2021
Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

Works great and code changes look good. Nice cleanup! 👏

@mikejolley do you think this PR needs a dev note or something similar? My understanding is that it will impact any theme/plugin that relies on our script/style handles.

@mikejolley
Copy link
Member Author

@Aljullu I'm uncertain — the scripts and styles we've changed are our own block handles (the external packages, price, and checkout, were not changed). Can you think of a use case where someone would use these handles?

@Aljullu
Copy link
Contributor

Aljullu commented Jun 9, 2021

@Aljullu I'm uncertain — the scripts and styles we've changed are our own block handles (the external packages, price, and checkout, were not changed). Can you think of a use case where someone would use these handles?

Yeah... I'm not sure. I'm thinking on a store that uses WooCommerce but none of WooCommerce Blocks, which might have unregistered our styles/scripts? Not sure if that's a case we need to account for, though, sounds very edge-case. Leaving the decision to you.

@mikejolley mikejolley added needs: dev note PR that has some text that needs to be included in the release notes. and removed skip-changelog PRs that you don't want to appear in the changelog. labels Jun 9, 2021
@mikejolley
Copy link
Member Author

Added a note 👍🏻

@mikejolley mikejolley merged commit f99a0f2 into trunk Jun 9, 2021
@mikejolley mikejolley deleted the docs/asset-handles branch June 9, 2021 14:09
@mikejolley mikejolley added this to the 5.4.0 milestone Jun 9, 2021
@senadir senadir added the type: enhancement The issue is a request for an enhancement. label Jun 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: dev note PR that has some text that needs to be included in the release notes. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Establish a consistent naming schema for asset handles.
3 participants