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

Ignore dashicons imports #2664

Merged
merged 5 commits into from Jun 8, 2020
Merged

Ignore dashicons imports #2664

merged 5 commits into from Jun 8, 2020

Conversation

nerrad
Copy link
Contributor

@nerrad nerrad commented Jun 8, 2020

Fixes: #2280

As a part of using Notice components from @wordpress/components directly for our new notices system, the dashicon package ended up getting pulled in for anything using notices. This resulted in an increase of ~85kb (unminified) for all builds!

While dashicons are removed in later iterations of @wordpress/components, we're unable to bump up our dependencies yet because of issues with non-available packages in the versions of WP we support.

While we do have some components using dashicons (from the package version we use) the solution is to use the webpack.NormalModuleReplacementPlugin to replace any dashicons imports with a custom version that eliminates the excessive size.

To test

This impacts anything loading our notices components. While this includes the new Product Block, because this is blocking 2.7.0, testing should primarily focus on:

  • All Products
  • Cart and Checkout.

Essentially testing involves:

  • ensuring the frontend and editor views load without console errors.
  • ensuring notices work as expected. I tested using coupons and also submitting the checkout with a empty required field (to trigger the error notice). Make sure the "dismiss x" icon shows up on the notice
  • ensure the little down arrow on select dropdowns (in the checkout) show up correctly

@nerrad nerrad requested a review from a team as a code owner June 8, 2020 11:02
@nerrad nerrad requested review from mikejolley and removed request for a team June 8, 2020 11:02
@nerrad nerrad self-assigned this Jun 8, 2020
@nerrad nerrad added focus: performance The issue/PR is related to performance. block: all products Issues related to the all products block. block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. block: single product Issues related to the single product block. labels Jun 8, 2020
@nerrad nerrad added this to the 2.7.0 milestone Jun 8, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2020

Size Change: -168 kB (10%) 👏

Total Size: 1.57 MB

Filename Size Change
build/active-filters-frontend.js 7.21 kB +5 B (0%)
build/active-filters.js 7.94 kB +1 B
build/all-products-frontend.js 38.5 kB -33.8 kB (87%) 🏆
build/all-products.js 20.8 kB +264 B (1%)
build/all-reviews.js 9.52 kB -3 B (0%)
build/attribute-filter-frontend.js 16.7 kB +1 B
build/attribute-filter.js 11.5 kB +2 B (0%)
build/block-error-boundary.js 775 B +1 B
build/blocks.js 2.92 kB +3 B (0%)
build/cart-frontend.js 63.6 kB -33.8 kB (53%) 🏆
build/cart.js 32.9 kB +263 B (0%)
build/checkout-frontend.js 80.1 kB -33.9 kB (42%) 🎉
build/checkout.js 38.4 kB +253 B (0%)
build/featured-category.js 7.59 kB +3 B (0%)
build/handpicked-products.js 7.24 kB +4 B (0%)
build/price-filter-frontend.js 14.1 kB +13 B (0%)
build/price-filter.js 10 kB -2 B (0%)
build/product-best-sellers.js 7.31 kB +2 B (0%)
build/product-categories.js 3.21 kB -1 B
build/product-category.js 8.22 kB +2 B (0%)
build/product-new.js 7.47 kB +2 B (0%)
build/product-on-sale.js 7.87 kB +4 B (0%)
build/product-search.js 3.43 kB +4 B (0%)
build/product-top-rated.js 7.45 kB +1 B
build/products-by-attribute.js 8.19 kB +3 B (0%)
build/reviews-by-category.js 11.5 kB -1 B
build/reviews-frontend.js 8.9 kB -9 B (0%)
build/single-product-frontend.js 41.3 kB -33.8 kB (81%) 🏆
build/single-product.js 15 kB +262 B (1%)
build/style-rtl.css 17.1 kB +108 B (0%)
build/style.css 17.1 kB +103 B (0%)
build/vendors.js 414 kB -34 kB (8%)
ℹ️ View Unchanged
Filename Size Change
build/all-reviews-legacy.js 9.21 kB 0 B
build/block-error-boundary-legacy.js 775 B 0 B
build/blocks-legacy.js 2.92 kB 0 B
build/custom-select-control-style-legacy.js 782 B 0 B
build/custom-select-control-style.js 783 B 0 B
build/editor-legacy-rtl.css 12.5 kB 0 B
build/editor-legacy.css 12.5 kB 0 B
build/editor-rtl.css 13.5 kB 0 B
build/editor.css 13.5 kB 0 B
build/featured-category-legacy.js 7.27 kB 0 B
build/featured-product-legacy.js 9.51 kB 0 B
build/featured-product.js 9.84 kB 0 B
build/handpicked-products-legacy.js 6.91 kB 0 B
build/product-best-sellers-legacy.js 6.99 kB 0 B
build/product-categories-legacy.js 3.22 kB 0 B
build/product-category-legacy.js 7.91 kB 0 B
build/product-list-style-legacy.js 774 B 0 B
build/product-new-legacy.js 7.15 kB 0 B
build/product-on-sale-legacy.js 7.52 kB 0 B
build/product-search-legacy.js 3.14 kB 0 B
build/product-tag-legacy.js 6.08 kB 0 B
build/product-tag.js 6.39 kB 0 B
build/product-top-rated-legacy.js 7.12 kB 0 B
build/products-by-attribute-legacy.js 7.88 kB 0 B
build/reviews-by-category-legacy.js 11.2 kB 0 B
build/reviews-by-product-legacy.js 12.7 kB 0 B
build/reviews-by-product.js 13 kB 0 B
build/reviews-frontend-legacy.js 8.05 kB 0 B
build/snackbar-notice-style-legacy.js 778 B 0 B
build/snackbar-notice-style.js 779 B 0 B
build/spinner-style-legacy.js 772 B 0 B
build/spinner-style.js 772 B 0 B
build/style-legacy-rtl.css 5.5 kB 0 B
build/style-legacy.css 5.5 kB 0 B
build/vendors-legacy.js 366 kB 0 B
build/vendors-style-legacy-rtl.css 1.03 kB 0 B
build/vendors-style-legacy.css 1.03 kB 0 B
build/vendors-style-legacy.js 103 B 0 B
build/vendors-style-rtl.css 1.03 kB 0 B
build/vendors-style.css 1.03 kB 0 B
build/vendors-style.js 102 B 0 B
build/wc-blocks-data.js 7.08 kB 0 B
build/wc-blocks-middleware.js 931 B 0 B
build/wc-blocks-registry.js 1.79 kB 0 B
build/wc-payment-method-cheque.js 794 B 0 B
build/wc-payment-method-paypal.js 830 B 0 B
build/wc-payment-method-stripe.js 11.9 kB 0 B
build/wc-settings.js 2.14 kB 0 B
build/wc-shared-context.js 1.51 kB 0 B

compressed-size-action

Copy link
Member

@senadir senadir left a comment

Choose a reason for hiding this comment

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

I did a code only review and this looks fine and clean to me.

Comment on lines 7 to 9
const iconClass = [ 'dashicon', 'dashicons-arrow-down-alt2', className ]
.filter( Boolean )
.join( ' ' );
Copy link
Member

Choose a reason for hiding this comment

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

why not use classnames, a dependency we already use (that is quite lightweight).

Copy link
Member

Choose a reason for hiding this comment

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

+1 I have same qu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I copy/pasted from gb for this blindly :). I'll add.

return (
<SVG
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
Copy link
Member

Choose a reason for hiding this comment

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

not sure how will the icon render, but if we want to keep with Gutenberg new grid system, this should be changed to "-2 -2 24 24", but if the icon renders fine and sharp, we should be okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Icon seems to be rendering fine, this was copied and pasted directly from the existing dashicons implementation. Since this is mostly temporary (we can replace once we can bump component versions), not sure if we need to change.

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.

Tested here too, couldn't spot anything weird and the size changes are great! 👏

const WebpackRTLPlugin = require( 'webpack-rtl-plugin' );
const chalk = require( 'chalk' );
const { omit } = require( 'lodash' );
const NODE_ENV = process.env.NODE_ENV || 'development';

const dashIconReplacmentModule = path.resolve(
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo:

Suggested change
const dashIconReplacmentModule = path.resolve(
const dashIconReplacementModule = path.resolve(

@Aljullu Aljullu added the skip-changelog PRs that you don't want to appear in the changelog. label Jun 8, 2020
Comment on lines 7 to 9
const iconClass = [ 'dashicon', 'dashicons-arrow-down-alt2', className ]
.filter( Boolean )
.join( ' ' );
Copy link
Member

Choose a reason for hiding this comment

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

+1 I have same qu

.filter( Boolean )
.join( ' ' );
return (
<SVG
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if you did or not, but I tested and some very small savings could be made if running the SVG though https://jakearchibald.github.io/svgomg/ - I do this on all icon imports I introduce.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just copied and pasted directly from the existing dashicons... are the savings enough to warrant implementing?

Copy link
Contributor Author

@nerrad nerrad Jun 8, 2020

Choose a reason for hiding this comment

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

Ya the difference is super miniscule, not worth the change imo (1byte)

Copy link
Member

Choose a reason for hiding this comment

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

168 bytes → 138 bytes for the X

Copy link
Contributor Author

@nerrad nerrad Jun 8, 2020

Choose a reason for hiding this comment

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

Really? it was only 1B when I used the tool, maybe I'm using it wrong (169->168B)

@Aljullu Aljullu mentioned this pull request Jun 8, 2020
11 tasks
@nerrad nerrad merged commit 4e02035 into master Jun 8, 2020
@nerrad nerrad deleted the fix/ignore-dashicons branch June 8, 2020 15:27
Aljullu added a commit that referenced this pull request Jun 8, 2020
@Aljullu Aljullu removed the skip-changelog PRs that you don't want to appear in the changelog. label Jun 8, 2020
Aljullu added a commit that referenced this pull request Jun 9, 2020
* Add 2.7.0 changelog

* Add 2.7.0 testing steps

* Add #2664 to readme

* Update testing notes to add checklist app creation link

* Add note that 'No shipping methods placeholder when they are all disabled' requires WC 4.3

* Bumping version strings to new version.

* Update readme.txt date

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: all products Issues related to the all products block. block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. block: single product Issues related to the single product block. focus: performance The issue/PR is related to performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Evaluate if we can move away from Notice component
5 participants