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

[v5] [icons] fix static icon component size, remove built-in webpack loaders #6222

Merged
merged 9 commits into from
Jun 14, 2023

Conversation

adidahiya
Copy link
Contributor

@adidahiya adidahiya commented Jun 14, 2023

Fixes #6220

Changes proposed in this pull request:

  • fix implementation of size prop for generated icon React components
  • fix: reduce bundle size by removing webpack-annotated icon path loaders
    • ⚠️ BREAK: IconLoaderOptions now accepts { loader: "split-by-size" | "all" | IconPathsLoader }
    • These webpack loaders created more bundle size inflation than they're worth because of the auto-generated namespace objects created by webpack to map path module filepaths to their source modules. We can achieve the same behavior as the existing "lazy-once" default by writing our own await import() statements. If users want to customize loading behavior, they can easily specify a custom loader function. Docs have been updated to reflect this

@adidahiya
Copy link
Contributor Author

Deferring imports of the webpack loaders seems to have helped, as the bulky generated namespace objects are now in separate chunks. But this causes webpack to generate chunks for every possible loading mode, which means many small chunks for icons. This is unnecessary noise that should be avoided when using the default Blueprint APIs:

image

@adidahiya
Copy link
Contributor Author

better now:

image

@adidahiya
Copy link
Contributor Author

Fix typo

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@adidahiya adidahiya marked this pull request as ready for review June 14, 2023 16:22
@adidahiya
Copy link
Contributor Author

adidahiya commented Jun 14, 2023

The "lazy-once" API is adding 170kb of "parsed" size to the bundle in a new chunk. Not sure if this is worth it for the default behavior:

image

... especially since we can emulate this "lazy-once" behavior quite easily ourselves with a couple await import() statements.

@adidahiya adidahiya changed the title [v5] [icons] fix static icon component size, defer webpack loader imports [v5] [icons] fix static icon component size, remove built-in webpack loaders Jun 14, 2023
@adidahiya
Copy link
Contributor Author

even better now:

image

@adidahiya
Copy link
Contributor Author

Remove built-in webpack loaders

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@adidahiya
Copy link
Contributor Author

Delete dead code

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@adidahiya adidahiya merged commit dd0a841 into next Jun 14, 2023
@adidahiya adidahiya deleted the ad/v5-beta.2-fixes branch June 14, 2023 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant