Notistack: Huge file size

Created on 11 Sep 2019  路  9Comments  路  Source: iamhosseindhv/notistack

Seems like it's even bigger than react. How can be possible?

withsnackbar

All 9 comments

Most of the bundle size seems to come from Material-UI: Compare notistack (7kB) with Snackbar (23 kB). Which, in turn, seems to come from JSS.

Yes, it is rather large: https://bundlephobia.com/[email protected]

As you can see most the size is actually the library this is where most reductions could be made. Although other areas are:

  • Using babel transform to remove prop-types for production
  • moving to clsx from classnames (this is what mui uses anyway, treeshaking would remove this)
  • Export an esm build so tree shaking is enabled - currently its not...

Some big wins without even reducing code size where there would be ... massive ... wins

Another leverage I have just thought of. Instead of a custom alert component, we could explore using this one: https://material-ui.com/components/alert/.

Agreed. Currently for a notifications stack, its pretty huge. Its about the same size as react-router.

@andrewmclagan What other dependencies do you have in your package.json? (looking for opportunities of third-party libraries to reduce bundle size)

Just installed notistack 0.9.11 and it adds ~50KB to my builds using parcel build --experimental-scope-hoisting. I'm hoping more bundle size optimizations can be done. On a small preact + material-ui page that 50KB is 20% of my 250KB bundle.

Of course improving bundle size is an ongoing thing and there's always room for improvement, but https://github.com/iamhosseindhv/notistack/pull/268 made a good step towards a smaller bundle size.
Screenshot 2020-05-15 at 03 19 22
Closing this but always open to suggestions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cevr picture cevr  路  7Comments

VincentLanglet picture VincentLanglet  路  3Comments

usama-asfar picture usama-asfar  路  3Comments

RastislavMirek picture RastislavMirek  路  8Comments

VincentLanglet picture VincentLanglet  路  5Comments