Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any possibility of reducing bundle size? #728

Open
etc-tiago opened this issue Jan 22, 2022 · 7 comments
Open

Any possibility of reducing bundle size? #728

etc-tiago opened this issue Jan 22, 2022 · 7 comments
Labels
status: help wanted requesting help from the community type: twilio enhancement feature request on Twilio's roadmap

Comments

@etc-tiago
Copy link

Today the entire package is over 13 mb. I'm using webpack to merge the code into a single file to run on AWS Lambda and about 96% of the package is from twilio.

One of the possibilities is to make the package more modular. AWS did this with the SDK and the result is very significant.

When using only S3, in version 2, it compiled about 69 mb. With version 3, only 3.9 mb.

Any chance of this happening with this twilio package?

@beebzz
Copy link

beebzz commented Jan 27, 2022

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

@beebzz beebzz added the type: question question directed at the library label Jan 27, 2022
@VigneshMurugan
Copy link

+1

@eshanholtz eshanholtz added the status: help wanted requesting help from the community label Feb 8, 2022
@imthatcarlos
Copy link

+1

@shwetha-manvinkurke shwetha-manvinkurke added type: twilio enhancement feature request on Twilio's roadmap and removed type: question question directed at the library labels Feb 15, 2022
@jimmywarting
Copy link

+1

for instance, change axios for built in fetch in NodeJS, if fetch isn't provided by the env, let user polyfill it themself with either undici, node-fetch or other

@luisgrases
Copy link

+1

@mariomui
Copy link

mariomui commented Jan 6, 2023

Screen Shot 2023-01-06 at 5 56 02 AM

Solution: I spun up webpack, set it to target node, and terser-packed twilio-sdk into a single file (2mb)
command to run npm run pack:analyze that produces an html

code can be found here: https://github.com/mariomui/twilio-node/tree/smaller-build

Observations:
a) lodash isn't used at all but is still sizable.
b) using (originally) tsc produces a 13mb lib
c) using babel-loader(before minify) : 5mb , applying terser(after minify with base options): 2 mb
d) If each function was in its own package (lerna/turborepo style) but requires gradual dev-time and maintainer buy-in. A terser pack-in seems to be the quick interim solution.
d) heavy testing is required to see if this compressed package works. (although i don't see why it shouldnt')
e) axios is a tiny dep in the great scheme of things.

Summary:
I added 7 or 8 webpack + babel dev dependencies in order to minify it down. Not sure if we should do that.
Turbopack and esbuild/rollup was considered but I was more familiar with webpack and its analyzer tools.
Turbopack was also missing documentation on its minifying capabilities.

Prolly need a discussion on whether or not minifying it for lambdas is a good stop gap measure.

@beebzz
Copy link

beebzz commented Jan 26, 2023

Hey folks, we've recently released version 4.0.0 of twilio-node which introduces a ~30% reduction in bundle size. Community support is also welcome for any further contributions or propositions to reduce bundle size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: twilio enhancement feature request on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

9 participants