-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
Improve lodash imports to reduce size of serverless bundles #298
Conversation
I like that, thanks @luisherranz! |
That was fast. Thanks @neoziro! :) |
I am not sure what this fixed for you @luisherranz because serverless will still install and include the entire lodash library inside the lambda since the dependencies inside @loadable/server's package.json didn't change. Wouldn't you want to remove lodash, and install lodash.uniq, lodash.uniqBy and lodash.flatMap? Maybe I am missing something :) |
@bitttttten it works if you build your bundle using webpack or ncc but I agree that maybe adding them as packages may cover more cases. |
Ohh I see. I am not using webpack to bundle my lambdas! To be honest I didn't ever think of doing that. I guess that answers my question, thanks! If you bundle your lambda with webpack, then wouldn't you loose all the niceties of the console editor? Or does it some how keep all that? |
I'm not familiar with AWS because I use other service. If code don't need to be bundled, then maybe it's not a good idea to make it necessary if someone is using loadable component. Could you please describe what is the normal workflow in AWS? |
use webpack alias to resolve dependencies |
use webpack externals to keep |
Can you run require on a lambda? And require node modules on that side? |
Of course, you can. Majority of lambdas(they were not created just for SSR task) are written in pure |
Summary
Serverless is becoming popular and bundle size is important. This PR avoids importing the whole lodash code, even in the server.
Test plan
Tests pass for
ChunkExtractor.js
, the only affected file.