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

Limits length of readable identifier in default stats #16479

Conversation

trevorgithub
Copy link

Reduces the length of the readable identifier shown in webpack output, so the user is not overwhelmed with large blocks of text. Fixes # 16475

Please see issue #16475

What kind of change does this PR introduce?
Changes the build output so that long strings are truncated (elided) to make more readable

Did you add tests for your changes?

No. Please advise where I would add tests. I looked in the project for tests of DefaultStatsFactoryPlugin.js, but I couldn't find any tests.

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

I'm not sure anything needs to be documented. I suppose somewhere it could say that identifiers in the build output will be truncated after hitting a maximum length, and truncation will be indicated by the presence of some ellipsis

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 15, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

@alexander-akait
Copy link
Member

Can you use your email (in github) for git commit, so CLA will be assigned

@trevorgithub
Copy link
Author

Can you use your email (in github) for git commit, so CLA will be assigned

Ok. I was hoping to keep my personal email out of the commit history. But I guess it's needed. I'm sure I'll have more commits, so I will include it in future commits

@alexander-akait
Copy link
Member

You need to have all commits with your email (used in github, you can create two emails if you want more security and use only one for such cases), this commit can be rewritten and forcely pushed

@trevorgithub
Copy link
Author

You need to have all commits with your email (used in github, you can create two emails if you want more security and use only one for such cases), this commit can be rewritten and forcely pushed

Alright, I'll see what I can do

@trevorgithub
Copy link
Author

@alexander-akait , aside from the CLA authorization, it looks there's one other check related to code coverage integration failing. Here's the link:

https://app.codecov.io/gh/webpack/webpack/pull/16479

I'm not clear on how my change impacted code coverage in the other area. Any suggestions?

@alexander-akait
Copy link
Member

@trevorgithub ignore this, it is not requried (metric for us)

Reduces the length of the readable identifier shown in
webpack output for external modules, so the user is not
overwhelmed with large blocks of text. See issue # 16475
@trevorgithub trevorgithub force-pushed the limit-identifier-length-in-default-stats branch from 2f9f1ae to e38b5f7 Compare November 17, 2022 21:50
@trevorgithub
Copy link
Author

@alexander-akait , I squashed the commits and redid the one commit so that my email address associated with my github account is now used. Looks like the CLA check is happy now. I guess you need to do something to approve running the workflows...

@alexander-akait
Copy link
Member

Thank you

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

/cc @TheLarkInn What do you think about it?

Copy link
Member

@TheLarkInn TheLarkInn left a comment

Choose a reason for hiding this comment

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

Because this code is located in the default/hot path for the user, can you please add a StatsCases test for this and also include snapshots.

Although the logic looks fine to me, we should have coverage over the default user path.

readableIdentifier,
module
) => {
const maxLength = 80;
Copy link
Member

Choose a reason for hiding this comment

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

Hoist this to the top of the file as a constant and use CONSTANT_CASE for the name. Reassigning continuously in this function adds unneeded memory pressure.

I would probably go with something like: MAX_EXTERNAL_MODULE_READABLE_IDENTIFIER_LENGTH

const maxLength = 80;
return module instanceof ExternalModule &&
readableIdentifier.length > maxLength
? readableIdentifier.substring(0, maxLength) + "..."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
? readableIdentifier.substring(0, maxLength) + "..."
? readableIdentifier.substring(0, maxLength) + "...(truncated)"

cc @alexander-akait I think its more user friendly if its blatantly obvious that truncation is happening. The ellipsis alone is not clear enough.

Copy link
Member

Choose a reason for hiding this comment

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

Agree, let's add (truncated)

Copy link
Author

Choose a reason for hiding this comment

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

@TheLarkInn , @alexander-akait Thanks for your feedback on this pull request. In the original issue, 16475, Zack suggested an alternate way to achieve my goal using delegated modules. I have used his idea, and it is sufficient for my needs. As a result, I'm not going to continue with this pull request. If you think it has value outside of my needs, feel free to make the changes that you suggested. Otherwise, please feel free to close the pull request.

Copy link
Member

Choose a reason for hiding this comment

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

@snitin315 Maybe you want to finish it? 😄

Copy link
Member

Choose a reason for hiding this comment

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

Sure. I'll finish it.

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

Successfully merging this pull request may close these issues.

None yet

6 participants