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

switch hex-rgb to polished parseToRgb #18681

Merged
merged 3 commits into from Nov 25, 2019
Merged

Conversation

@jameslnewell
Copy link
Contributor

jameslnewell commented Nov 22, 2019

Description

Temporary fix for the issue discussed in #17963 (comment)

Replaced the hex-rgb package+function for polished's parseToRgb function since the hex-rgb package doesn't provide any transpiled modules.

Polished is 10kb gziped but highly treeshakable.

How has this been tested?

Ran unit tests, checked the storybooks.

Screenshots

No visual changes.

Types of changes

Bug fix.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

closes #18719

@aduth

This comment has been minimized.

Copy link
Member

aduth commented Nov 22, 2019

Thanks for jumping on this so quickly.

One downside here is that it's about a 1400% size increase from hex-rgb (0.7kb to 10.6kb).

I can plan to look a little closer in my morning. It'd be good to have this resolved in time for next week's release, so if it comes down to it, we can live with the larger bundle until another solution presents itself.

@jameslnewell

This comment has been minimized.

Copy link
Contributor Author

jameslnewell commented Nov 22, 2019

Yeah if treeshaking isn't supported its a big hit. I can see a few alternatives but they're only 50% better:

@@ -2,7 +2,7 @@
* External dependencies
*/
import { get } from 'lodash';
import hexRgb from 'hex-rgb';
import { parseToRgb } from 'polished';

This comment has been minimized.

Copy link
@youknowriad

youknowriad Nov 22, 2019

Contributor

I think we already have tinycolor2 in our bundles. We could use it instead right?

This comment has been minimized.

Copy link
@ItsJonQ

ItsJonQ Nov 22, 2019

Contributor

@jameslnewell Ah, you folks are so fast! You jumped on this before I could :)
I was going to suggest using tinycolor2 since it was already there. My apologies for not realizing that when I submitted my original PR.

Thanks for the heads up @youknowriad + @aduth !

@aduth

This comment has been minimized.

Copy link
Member

aduth commented Nov 22, 2019

Polished is 10kb gziped but highly treeshakable.

Based on what I see in that link, it's not very well tree-shaken, since the total bundle is 10.8kb gzipped, and the single parseToRgb function is still 10.6kb.

I've pushed up a change here to use tinycolor2, since as mentioned we already have it available in the module.

@aduth
aduth approved these changes Nov 22, 2019
Copy link
Member

aduth left a comment

Assuming latest changes look good to you, I think we can merge this 👍

@jameslnewell jameslnewell requested a review from ellatrix as a code owner Nov 22, 2019
@aduth aduth added this to the Gutenberg 7.0 milestone Nov 23, 2019
@youknowriad youknowriad merged commit 342cdd1 into WordPress:master Nov 25, 2019
2 checks passed
2 checks passed
pull-request-automation
Details
Travis CI - Pull Request Build Passed
Details
@jameslnewell jameslnewell deleted the jameslnewell:fix-hex-rgb branch Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.