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

Reduce installation size #609

Merged
merged 6 commits into from
Aug 3, 2023

Conversation

SukkaW
Copy link
Contributor

@SukkaW SukkaW commented Aug 2, 2023

The PR follows #505. The PR reduces node_modules size after npm i webpack-bundle-analyzer with 2 changes:

  • Replaces chalk with picocolors
  • Replaces lodash with individual lodash.* packages.

Comparison

Running npm i --omit=dev --omit=optional against webpack-contrib/webpack-bundle-analyzer:master:

image

Running npm i --omit=dev --omit=optional against sukkaw/webpack-bundle-analyzer:optimize-install-size:

image

@SukkaW SukkaW marked this pull request as draft August 2, 2023 15:02
@SukkaW SukkaW marked this pull request as ready for review August 2, 2023 15:21
Copy link
Member

@valscion valscion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍. Can you add more changelog entries as well?

.compact()
.flatten()
.uniqBy('id')
// Filtering out Webpack's runtime modules as they don't have ids and can't be parsed (introduced in Webpack 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep these documentation comments as they give reasoning why certain logic exists :)

Copy link
Contributor Author

@SukkaW SukkaW Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I keep forgetting about this!

Copy link
Member

@valscion valscion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah looks good to me 👍

@valscion valscion merged commit e2a6479 into webpack-contrib:master Aug 3, 2023
6 checks passed
@valscion
Copy link
Member

This PR and #505 have been released in v4.9.1 now ☺️. Thank you for your contributions!

@stof
Copy link

stof commented Sep 12, 2023

the usage of those individual packages is discouraged: https://lodash.com/per-method-packages

Also, as soon as another package also depends on lodash, this change actually increases the size of node_modules as lodash was deduplicated before.

@valscion
Copy link
Member

Thanks @stof. So we should probably revert these changes then. @SukkaW would you be up for that?

@SukkaW
Copy link
Contributor Author

SukkaW commented Sep 12, 2023

Thanks @stof. So we should probably revert these changes then. @SukkaW would you be up for that?

For most of my projects, the only copy of lodash was introduced by the webpack-bundle-analyzer.

Since lodash is essentially dead (hasn't been maintained for years), IMHO instead of reverting back to lodash, replacing all lodash.* packages with maintained, performant, and lightweight packages would be a better approach. I will have opened a PR (#612) to do that.

@stof
Copy link

stof commented Sep 12, 2023

Well, lodash is indeed kinda dead since 3 years. But the per-method packages have last been released 7 years ago. So they are still missing 4 years of work in the lodash package.

@SukkaW SukkaW mentioned this pull request Apr 7, 2024
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.

None yet

3 participants