optimize alias plugin for huge alias objects#438
optimize alias plugin for huge alias objects#438VincentBailly wants to merge 5 commits intowebpack:mainfrom
Conversation
|
| 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.
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.
There was a problem hiding this comment.
If the aliasing object gets truly large, it'd be worth investing in adding a dependency on a prefix-tree implementation that can handle the optional * component in the path, and use that to optimize the matching logic.
There was a problem hiding this comment.
To avoid shape changes it would be best to have this.options consist of fresh objects that have all required properties.
|
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: