calibreapp/react-live-chat-loader

Bundle size

jaska120 opened this issue · 3 comments

All components are being bundled when using Gatsby V3 and Webpack V5, see screenshot.

image

I think it is due to fact that providers are exported as object instead of named exports (https://github.com/calibreapp/react-live-chat-loader/blob/main/src/providers/index.ts).

Changing exports and then using named imports like:
import * as Providers from 'providers' in (https://github.com/calibreapp/react-live-chat-loader/blob/main/src/components/LiveChatLoaderProvider.tsx#L2)

might make them tree-shakeable. Could you look into this?

Hi @jaska120, it looks like there's a regression in bundle size starting at the current version of react-live-chat-loader (2.3.3).

I'd recommend using 2.3.2 for now.

Otherwise, if you've capacity to help explore this issue further please feel free to leave notes on this tracking issue.

I dig a little bit into this.

Babel is used to compile all the code to CommonJS and therefore webpack is not able to tree-shake this package properly. I would suggest to compile es6 module version of this package and add additional module reference to package.json so that projects using webpack etc. for tree-shaking can use smaller bundle sizes.

seems like issue has been solved for components, would be great to do the same with providers

Screenshot 2022-11-14 at 10 13 10