Skip to content

Reduce installation size#609

Merged
valscion merged 6 commits intowebpack:masterfrom
SukkaW:optimize-install-size
Aug 3, 2023
Merged

Reduce installation size#609
valscion merged 6 commits intowebpack:masterfrom
SukkaW:optimize-install-size

Conversation

@SukkaW
Copy link
Copy Markdown
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 force-pushed the optimize-install-size branch from 3032caa to 4523798 Compare August 2, 2023 15:19
@SukkaW SukkaW marked this pull request as ready for review August 2, 2023 15:21
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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:master Aug 3, 2023
@valscion
Copy link
Copy Markdown
Member

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

@stof
Copy link
Copy Markdown

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
Copy Markdown
Member

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

@SukkaW
Copy link
Copy Markdown
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
Copy Markdown

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.

3 participants