Duplicated and whole library in bundle

I am using the preact CLI to bundle my application which is using JSONForms with the react renderers. I noticed that the bundle is really big (over halb MB with nearly now application code). When using the bundle analyzer i see two issues:

  1. AJV is included twice in the bundle
  2. lodash is included as the full library and not only the functions which are actually in use

Has anyone had a similar problem and knows a solution? Could the cause be that i am using preact instead of react?


a

Thanks!

Hi!

  1. AJV is included twice in the bundle

When I run the bundle analyzer on our React seed then AJV is only included once. Can you check whether you have a (indirect) dependency on AJV in your application code which might lead it to be included in two versions? Note that AJV is not a peer dependency in JSON Forms at the moment, therefore you need to use the version of JSON Forms to avoid it being included twice. For version 3.0.0 the range in JSON Forms is set to ^8.6.1.

  1. lodash is included as the full library and not only the functions which are actually in use

Are you sure that lodash is fully included for you? It looks like the bundle analyzer was able to distinguish its content as it usually displays lodash as one huge block when it was included in full. Again checking the React seed, yes a lot of lodash is included but definitely not all of it. For example isEmpty is used a lot and is included but zipWith is not used anywhere in the JSON Forms code base and is also not included in the Webpack build.