-
Notifications
You must be signed in to change notification settings - Fork 190
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
optimize alias plugin for huge alias objects #438
base: main
Are you sure you want to change the base?
Conversation
|
@@ -23,6 +22,9 @@ module.exports = class AliasPlugin { | |||
constructor(source, options, target) { | |||
this.source = source; | |||
this.options = Array.isArray(options) ? options : [options]; | |||
for (const item of this.options) { | |||
item.nameWithSlash = item.name + "/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a memoization so we don't do this concatenation on every resolution, the concatenation creates an object that is short lived, creating work for the garbage collector. By creating the concatenated string once, storing it and reusing it we save the memory overhead of creating many times the same temporary objects.
Tests are failed |
The alias plugin gets very slow when the webpack config has many aliases.
This PR aims to re-implement the features of the current alias plugin but in a more efficient manner: