amplitude / Amplitude-TypeScript

TypeScript Amplitude Analytics SDK
https://amplitude.github.io/Amplitude-TypeScript/
MIT License
124 stars 33 forks source link

Bundle size #325

Open alexblack opened 1 year ago

alexblack commented 1 year ago

I'm trying out migrating from amplitude-js to amplitude-browser, hoping that we'd achieve a smaller bundle size through tree shaking (we're using it in Remix which uses esbuild)

However, our bundle size has gone up by ~13kb, despite our careful import usage like import { track } from '@amplitude/analytics-browser'

Before:

Screen Shot 2023-02-07 at 4 10 22 PM

After:

Screen Shot 2023-02-07 at 4 10 27 PM
alexblack commented 1 year ago

Hmm that tslib.js, weighing in at 10kb 3x seems suspicious

stof commented 1 year ago

@alexblack could it be that your project dependencies contain both tslib 1.x and 2.x, and performs hoisting for the 1.x version thus installing 2.x multiple times ?