-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Move from local icons to polaris-icons #686
Conversation
b559f04
to
eb5f186
Compare
eb5f186
to
bd466cd
Compare
bd466cd
to
b208209
Compare
@BPScott @dfmcphee @kaelig @tmlayton @dleroux Hello friends, this PR is the first step in the rollout of the icons project. We originally talked about merging this into a beta branch, but looking at the scope of the changes, and considering that this change is purely architectural and shouldn't affect the end-user, I thought there might be a case for just merging this into master. I'm pinging all of you to know what your opinion is on this, and so that people across the team are aware that this is happening. Do you think we can merge this change into master directly? Any reservations, or feedback on the approach taken here? |
b208209
to
bf46eb2
Compare
@@ -10,7 +10,8 @@ const postcssShopify = require('postcss-shopify'); | |||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer') | |||
.BundleAnalyzerPlugin; | |||
|
|||
const ICON_PATH_REGEX = /icons\//; | |||
const INTERNAL_ICON_PATH_REGEX = /icons\//; |
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.
Anything that matches icons\/
would also match anything that matches polaris-icons\/
so I don't think this second regex is needed.
If we wanted to be stricter and match an exact folder name we could still do it in single regexp I think. Something like /\/(icons|polaris-icons)\//
would match both blah/icons/blah
and blah/polais-icons/blah
.
Fantastic work! Keeping I am a little wary of having a stable release of polaris depend upon a beta release of polaris-icons. I don't think we want to give that impression of beta unstableness to 3rd parties that consume polaris - even though I know this isn't going to result in any breaking changes or churn for consumers of polaris. I'm super excited by how close this is but I think it is worth getting those last bits of polish in the polaris-icons repo around using a monorepo structure and investigating making an esnext build, then cutting a v1.0.0 before we merge this into master |
Really happy to see this taking shape! |
This is a very good point, we wouldn't want to give our users the impression of fragility.
I'm already working on the monorepo, but that's not the reason I decided to make the package a beta. Like we talked about yesterday, there might be a better way of structuring exports so that tree-shaking is easier. If it did come to that, I would have to make breaking changes to the package. To avoid version numbers quickly growing I decided that making it a beta until we tried this out in production and were confident of it was the right choice. Do you think this is unnecessary? Maybe it's fine if we increase the major version numbers at first. |
Yep the changing exports thing is what I was more concerned about from a breaking-changes perspective. I totally agree with using beta versions to give us a chance to make those initial breaking changes without a spate of major version bumps. (My personal approach for that tends to be using 0.X.Y versions till I'm confident I've got a stable external API but using 1.0.0-beta-X has exactly the same effect) |
For context, the first time As Edit: |
bf46eb2
to
0d37ee1
Compare
As for the esnext build, I also looked into that. Tree-shaking only works with ESM modules. CJS is incompatible with ESM, so tree-shaking won't work out of the box with Because of this, I think it's ok to expose a single CJS script. By enforcing this structure, devs also get the benefits of typing and integration with IDEs, which will provide a better experience overall. |
All of the issues brought up have been addressed, and we're ready to move forward with this PR. I will be merging this PR around 3PM EST. If you have any questions or concerns please bring them up before then. |
@amrocha I am not sure I understand how the existing approach actually does tree shaking. When you do an import of an object (a default import or namespace import; in this case it is the default import from For tree shaking to work, you must have an ESNext (that is: preserves |
@lemonmade Thanks for pointing that out. I did some more extensive testing locally and it seems like you're right, the entire package gets imported into the bundle. I was under the impression that the project would be able to tree shake icons that weren't used if we had a setup like the I will look into exporting individual icons from That being said, currently both the ESM and CJS builds of |
Talked to Chris and we agree on shipping this as is since it's not a regression. There's a release going on right now though so I'll give it a day in case something goes wrong and we need to rollback. New plan is to merge tomorrow around noon |
Worth mentioning this in the changelog - in case anything goes wrong it'll be easier for people to track the possible source back to this PR. |
3f3d9dc
to
7225cc0
Compare
This reverts commit d847fc6.
WHY are these changes introduced?
There's an ongoing project to improve icon usage at Shopify (https://unicorn.shopify.io/projects/4785).
As part of this project we're making a new central repository to store our icons, and deploying a package from said repo containing all of our Icons.
This PR deletes all of the local icons, and switches to use
polaris-icons
instead. This change should be imperceptible to the user, and is only an architecture change.WHAT is this pull request doing?
Deleting local icons, replacing them with icons from the
polaris-icons
package. This is purely a plumbing change, and should have no effect on the end-user's experience.How to 🎩
Make sure bundle sizes don't change in consuming projects.
🎩 checklist