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

switch hex-rgb to polished parseToRgb #18681

merged 3 commits into from
Nov 25, 2019

Conversation

jameslnewell
Copy link
Contributor

@jameslnewell 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
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
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';
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link

Choose a reason for hiding this comment

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

@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
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.

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

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

@aduth aduth added this to the Gutenberg 7.0 milestone Nov 23, 2019
@aduth aduth added the Browser Issues Issues or PRs that are related to browser specific problems label Nov 23, 2019
@youknowriad youknowriad merged commit 342cdd1 into WordPress:master Nov 25, 2019
@jameslnewell jameslnewell deleted the fix-hex-rgb branch November 25, 2019 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Browser Issues Issues or PRs that are related to browser specific problems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editor broken on IE11
4 participants