react-admin-firebase icon indicating copy to clipboard operation
react-admin-firebase copied to clipboard

Importing lodash methods directly in order to reduce bundle sizes

Open KonkretneKosteczki opened this issue 3 years ago • 3 comments

Addressing issue https://github.com/benwinding/react-admin-firebase/issues/266 It's a pretty small change, so should not be difficult to review it

  1. Changed misc arrayHelpers and translate-from-firestore lodash imports
  2. Changed FireClient database provider lodash imports
  3. Updated package.json and yarn.lock to reflect the dependency changes

KonkretneKosteczki avatar Mar 29 '23 13:03 KonkretneKosteczki

@benwinding this could be a nice improvement to the actual bundle size of the project!

LorenzoCruccu avatar Mar 24 '24 12:03 LorenzoCruccu

Just as I suspected, this seems to have 0 effect on the bundle size, which is already tiny at 10kb

image

I think the bundler already helps with this, due to tree-shaking... Unless anyone can prove otherwise?

Maintaining dependencies for each helper function of lodash seems a bit insane to me...

benwinding avatar Mar 25 '24 00:03 benwinding

unfortunatly, i don't know how to analyze the bundle of this project (I will glad if you tell me how can i visualize it like webpack-bundle-analyzer), but as this commit of react-admin -> https://github.com/marmelab/react-admin/pull/9385 , cherry picking lodash is prefered due to dependencies resolution. In this way, you are 100% sure that you will inject only the lodash modules that are actually utilized.

As regards of maintaning each lodash dependency in the package.json, I agree with you that is not sustainable and importing just lodash is fine due treeshaking

LorenzoCruccu avatar Mar 26 '24 07:03 LorenzoCruccu