Commit 5cfa879
committed
perf: precompile AliasPlugin options to speed up huge alias lists
Hoists per-option strings (nameWithSlash, absolutePath, wildcardPrefix/Suffix)
out of the hot AliasPlugin scan into AliasUtils#compileAliasOptions, invoked
once per resolver in AliasPlugin#apply (and in TsconfigPathsPlugin when a
paths map is built). The per-resolve loop then runs with no string concat,
no name.split("*"), and no resolver.join per unmatched entry - the cost that
dominated projects with hundreds of webpack aliases (see #438).
Adds two benchmark cases covering the monorepo-scale scenario:
- huge-alias-list: 300 non-matching + 8 matching aliases, match near end
- huge-alias-miss: 300 aliases + requests that never match any
Local wall-clock numbers (Node 22, tinybench):
before after delta
huge-alias-list 225 ops 405 ops +80%
huge-alias-miss 453 ops 893 ops +97%
large-alias-list 653 ops 856 ops +31%
https://claude.ai/code/session_01ERSdt7j3dKwd9MxNbuuXnm1 parent b5259a0 commit 5cfa879
23 files changed
Lines changed: 256 additions & 38 deletions
File tree
- benchmark
- cases
- huge-alias-list
- fixture
- src
- target
- huge-alias-miss
- fixture
- src
- target
- lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments