stackdriver-errors-js icon indicating copy to clipboard operation
stackdriver-errors-js copied to clipboard

Reduce the bundle size

Open richardscarrott opened this issue 4 years ago • 4 comments

Currently requiring stackdriver-errors-js results in quite a lot of code being pulled in -- it's one of our largest dependencies.

Screenshot 2021-02-26 at 18 55 52

The above is generated using https://github.com/webpack-contrib/webpack-bundle-analyzer.

Stat Size: 136.64KB (before minification) Parsed Size: 39.06 KB (after minification) Gzipped: 11.65KB (after minification + gzip)

Although it's not strictly because of code in stackdriver-errors-js, I figured this is a good place to start to get an understanding of what really is required to report errors to stackdriver.

In particular I'd love to find out how important stacktrace-js is to this libraries functionality and whether there are opportunities to cut it or use an alternative dependency -- I wonder if it's supporting very old browsers / edge cases which are no longer relevant to everybody 🤔

I'm tempted to just try to write a simple stackdriver API wrapper without stacktrace-js but of course there's every chance I'll end up going through the exact same process this library went through and realise it's not possible without those large dependencies so any advice is welcome!

richardscarrott avatar Feb 26 '21 19:02 richardscarrott

stacktrace-js is needed for this library as it helps normalize the stacktraces before sending them to the server (stacktraces differ between browsers, e.g. Firefox / Chrome)

if you try to cut it, make sure to test with multiple browsers. We could make it optional (and provide two builds of the library).

steren avatar Mar 01 '21 21:03 steren

+1 also, https://github.com/GoogleCloudPlatform/stackdriver-errors-js/blob/ca41366ddbd8b5054b9f7112e461190f79e1eff7/gulpfile.js#L28-L34

currently there are some bundled polyfills for what, like IE 8 ? https://caniuse.com/?search=array.map

kospl avatar Mar 27 '21 15:03 kospl

I'm definitely supportive of dropping support for old browsers.

steren avatar Mar 29 '21 16:03 steren

@steren Added a PR for this https://github.com/GoogleCloudPlatform/stackdriver-errors-js/pull/106

bjon avatar Oct 14 '21 07:10 bjon