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

Fix duplicated lodash package when bundling react-admin without tree shaking #5380

Merged
merged 1 commit into from
Oct 11, 2020

Conversation

impronunciable
Copy link
Contributor

@impronunciable impronunciable commented Oct 11, 2020

Importing lodash instead of lodash/merge was having an impact in the ra-core import size for examples/demo.

This is lodash footprint before the change:

Screen Shot 2020-10-11 at 11 27 33

And after:

Screen Shot 2020-10-11 at 11 30 02

@fzaninotto
Copy link
Member

The import you changed is only one of many. You're supposed to use a bundler with tree-shaking ability to minimize your bundle size.

@fzaninotto fzaninotto closed this Oct 11, 2020
@impronunciable
Copy link
Contributor Author

Actually it was the only one importing the main lodash module. That's why I got the file size reduction. I think this would be beneficial for every ra user even if they don't use a bundler with tree shaking

@fzaninotto
Copy link
Member

You're right, all the other imports use the alternative syntax. So not only does your PR improve bundle size for those not using a bundler with tree shaking, it also makes the code more consistent. Let me reopen and merge it.

@fzaninotto fzaninotto reopened this Oct 11, 2020
@fzaninotto fzaninotto merged commit 0a250f8 into marmelab:master Oct 11, 2020
@fzaninotto
Copy link
Member

Thanks for this patch. Note that using a bundler with tree shaking will reduce the bundle size even more (because we use mostly the import { XXX } from ... syntax for material-ui).

@impronunciable
Copy link
Contributor Author

Thank you and thanks for mantaining the project!

@fzaninotto fzaninotto added this to the 3.10.0 milestone Oct 11, 2020
@impronunciable impronunciable deleted the load-lodash-utility branch October 11, 2020 21:12
@fzaninotto fzaninotto changed the title Strip down lodash footprint by loading only the required utility Fix duplicated lodash package when bundling react-admin without tree shaking Oct 11, 2020
@fzaninotto fzaninotto modified the milestones: 3.10.0, 3.9.3 Oct 11, 2020
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.

2 participants