Skip to content

Comments

Better support for Serverless Framework#29

Open
dbryantm wants to merge 3 commits intofrankthelen:masterfrom
dbryantm:feature/serverless-bundling
Open

Better support for Serverless Framework#29
dbryantm wants to merge 3 commits intofrankthelen:masterfrom
dbryantm:feature/serverless-bundling

Conversation

@dbryantm
Copy link
Contributor

Reduces the size even further for projects that are using the Serverless Framework while bundling functions individually for AWS Lambdas. Otherwise it seems to still be bundling all of lodash even if the project doesn't require it.

Douglas Moore added 2 commits October 15, 2018 11:14
…ess Framework when you're bundling functions individually. Otherwise it seems to still be bundling all of lodash even if the project doesn't require it.
@dbryantm dbryantm changed the title Better support for Serverless Framework bundling Better support for Serverless Framework Oct 15, 2018
@coveralls
Copy link

coveralls commented Oct 16, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 46900aa on dbryantm:feature/serverless-bundling into ea75ed0 on frankthelen:master.

@Hakuz
Copy link

Hakuz commented Nov 25, 2018

To make the size more smaller, what about removing the bluebird with es6 native promise?

@dbryantm
Copy link
Contributor Author

I wouldn't disagree with that. I also think it wouldn't be a bad idea to move to using Babel so you can use imports and tree shaking. Some of the changes would be breaking enough that the maintainer would need to make those decisions though.

@frankthelen
Copy link
Owner

Yes, Bluebird could be removed without breaking anything, I think. I'll check it. Thanks.

@frankthelen
Copy link
Owner

@Hakuz @dbryantm
I removed Bluebird in favour of native promises (#30). Please review. All tests are green with Node 8/10/11.

@dbryantm
Copy link
Contributor Author

Merged the new version of master into the feature branch.

@dbryantm
Copy link
Contributor Author

@frankthelen, any chance you could review this? Thanks in advance!

@frankthelen
Copy link
Owner

Honestly, requiring lodash's individual method packages is an antipattern. In addition, they are not maintained anymore (deprecated). Rools depends on the main library, but requires individual packages, e.g., const intersection = require('lodash/intersection');. As far as I understand, this is exactly the way it should be done. And also should allow for tree shaking (which I haven't tried yet).

@dbryantm
Copy link
Contributor Author

dbryantm commented Dec 11, 2018

The only way to achieve tree shaking successfully with lodash is to use lodash-es instead and just require the individual functions such as:
const intersection = require('lodash-es/intersection'); or import { interesection } from 'lodash-es';.
There's some threads actually out there regarding this issue with webpack, such as webpack/webpack#6925 (comment). I think at least making that change would be a step in the right direction. Thoughts?

Also, I'd be glad to make those changes in another pull request if you would be willing to review it. Thanks in advance!

@frankthelen
Copy link
Owner

Unfortunately, on the Node side, ES modules are still flagged experimental, even in Node 10. And since Rools is supporting Node >= 8, this does not look like an option to me. Maybe we should eliminate lodash altogether. What Rools is using from it (intersection, isBoolean, isFunction, isInteger, isString) could easily also be achieved differently without lodash.

@frankthelen
Copy link
Owner

We could use https://www.npmjs.com/package/is for the validators.

@dbryantm
Copy link
Contributor Author

Yeah, that could possibly work though I would like to see the size of the library when it gets bundled with webpack. I could try some tests to see what the end results are.

@jonioni
Copy link

jonioni commented May 31, 2023

Lodash is now discouraging the use of per method packages (reference). With webpack5 wondering if this issue is still present? @dbryantm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants