bundle size
My team is trying to reduce the size of our app and twilio-taskrouter is one of the larger dependencies in the web app. Can efforts be made to reduce the size?
Two opportunities I see are:
- Use built-in web
fetchAPI instead ofaxios(either directly or via a thin wrapper for convenience methods, e.g.ky). - Avoid loading all (or any) of Lodash. Importing functions directly (rather than through
_) should allow tree shaking for webpack/rollup/etc. Another option is to use Lodash custom builds. Some or all of the usages can be replaced using modern ES built-ins too.twilio-taskroutercurrently only uses 13 methods fromlodash(excluding a few other usages in tests/specs):- difference
- every
- filter
- inRange
- isBoolean
- isDate
- isEmpty
- isInteger
- isNil
- isObject
- isString
- pick
- upperFirst
Thanks @mfulton26, we will go ahead and integrate proposed change for lodash. However axios dependency is slightly more complex, since we need to make sure this package can work on Mobile using React Native.
Thanks @mfulton26, we will go ahead and integrate proposed change for lodash. However axios dependency is slightly more complex, since we need to make sure this package can work on Mobile using React Native.
Sounds good to me. I think pulling in all of lodash into bundled web apps was my main concern. It does, however, appear that React Native does support the Fetch API: https://reactnative.dev/docs/network. Long term it may be good to move off of axios. (One less dependency to keep up to date, patch for new security vulnerability alerts, etc.)
Thank you.