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

Trim down install size by 5 mb by dropping lodash #13134

Closed
1 task
marvinhagemeister opened this issue Apr 11, 2021 · 3 comments · Fixed by #13139
Closed
1 task

Trim down install size by 5 mb by dropping lodash #13134

marvinhagemeister opened this issue Apr 11, 2021 · 3 comments · Fixed by #13139
Labels
i: enhancement i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@marvinhagemeister
Copy link
Contributor

marvinhagemeister commented Apr 11, 2021

Feature Request

  • I would like to work on this feature!

Is your feature request related to a problem?

Currently every babel installation installs lodash as a dependency, because it is required by @babel/types. This consumes 5MB of disk space for every babel installation.

$ du -h node_modules | sort -h
# ...snip
4.9M	node_modules/lodash
5.9M	node_modules/@babel
7.4M	node_modules/esbuild/bin
7.5M	node_modules/esbuild
8.0M	node_modules/prettier/esm
 17M	node_modules/rxjs
 18M	node_modules/prettier
 54M	node_modules/typescript/lib
 57M	node_modules/typescript
133M	node_modules
$ npm ls lodash
my-project@0.0.1 /Users/marvinhagemeister/dev/github/my-project
└─┬ @babel/core@7.13.14
  └─┬ @babel/types@7.13.14
    └── lodash@4.17.21

Doing a quick grep over babel's repo the lodash package is used for the following tasks:

A small footprint is desireable as it makes docker images smaller which in turn lead to faster deployments.

Describe the solution you'd like

Smaller install size. I did start a small ~4kb lodash clone a while back, but it's missing isPlainObject. The rest should work out of the box. Functions like getting the last element of an array should probably be just inlined though.

Describe alternatives you've considered.

Documentation, Adoption, Migration Strategy

@babel-bot
Copy link
Collaborator

Hey @marvinhagemeister! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@nicolo-ribaudo
Copy link
Member

Yeah at least last, isPlainObject and debounce can be easily inlined.

@hzoo
Copy link
Member

hzoo commented Apr 11, 2021

Agreed, we're happy to take a PR to inline these especially since a lot of them are only used once/in one place. Did a few of these kinds of PRs earlier #13057

For the particular thing about @babel/core, we can inline isPlainObject and remove it since it's the main reason

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: enhancement i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants