Repository navigation
Commit 038c301
authored
feat(performance): add five hints for problems bundling itself creates (#21821)
* feat(performance): add the asyncChunkWaterfalls hint
A chunk cannot be requested until the one importing it has arrived and
run, so an 'import()' chain costs a round trip per level before anything
below it starts. The chunk group graph already holds the depth; only the
end of each chain is reported, since every prefix of it is the same
finding said again.
* feat(performance): add the loadersOnNodeModules hint
Dependencies ship built, so a rule without 'exclude: /node_modules/'
spends build time redoing work — the most common reason a build is slow.
The count is per loader, and a case pins that application modules the
same loader handled are not counted.
* feat(performance): add the inlinedAssets hint
A data url is base64, so it costs about a third more than the file it
replaces, cannot be cached on its own, and is downloaded again whenever
the code around it changes. The parser already records whether it
inlined, so the check asks the module rather than reading its type.
* feat(performance): add the embeddedSourceMaps hint
The 'eval' and 'inline' devtool families write the map into the bundle,
so in a production build everyone loading the page downloads it. Cases
pin that a separate '.map', and the same devtool in development, stay
quiet.
* feat(performance): add the topLevelThis hint
At the top level of an ES module 'this' is 'undefined', so code moved
from CommonJS that reads it silently gets nothing — Rollup warns and
webpack was silent. Only bodies that rebind 'this' are skipped, so an
arrow function at the top level still counts, and CommonJS is left alone
because there 'this' is 'module.exports' and means what it says.
* feat(performance): add the constReassignment and namespaceCall hints
Both throw a TypeError where they run and webpack was silent about them.
Rather than a scope analysis on the parse path, only names with exactly
one binding in the module are considered: such a name cannot be shadowed,
so every mention of it is that binding. A shadowed name is left alone
instead of guessed at, which under-reports rather than failing a build
with 'hints: "error"' over something legal.
Also looks through scope hoisting in the four hints that read evidence
left at parse time: a concatenation is one module in the chunk graph but
several on disk, and the evidence sits on the ones that were parsed.
* test: update the option-surface snapshots for the seven new hints
The CLI flags are derived from the schema and the defaults snapshot
carries the whole resolved config, so each new property shows up in
both.
* test: type the loader fixture parameters
* feat(performance): drop the two hints that only a linter owes you
'constReassignment' and 'namespaceCall' report code that is broken with
or without a bundler, which ESLint and TypeScript already say and webpack
has no better view of. A hint earns its place by catching something
bundling caused.
'topLevelThis' stays and now says what webpack knows rather than what a
linter would: the file is being treated as an ES module — one 'import' or
'export' is enough for 'javascript/auto' to decide that — and 'this' is
'undefined' there rather than 'module.exports'.
* feat(performance): drop the loadersOnNodeModules hint
Transpiling a dependency is a choice rather than a defect — an ESM-only
package often needs it — so a loader touching 'node_modules' is not
something webpack can call wrong. It also reported what the build cost
rather than a problem with what the build produced.
* fix(performance): count 'this' in a class heritage clause and computed key
A class rebinds 'this' in its body, but its heritage clause and its
computed keys are evaluated where the class is written — so
'class C extends this.Base {}' reads the module's 'this' and was skipped
along with the body. Reverting to the wholesale skip fails the new case.
Also folds the four changesets into one, as the guide asks, and shortens
a comment past the two-line limit.
* test(performance): cover the hint ordering comparators
Every case reported a single waterfall, asset or module, so the three
sort comparators never ran and the documented order was untested. Each
base case now reports several, with the tie-break arm exercised too.1 parent 7b7f6dd commit 038c301
118 files changed
Lines changed: 1488 additions & 1 deletion
File tree
- .changeset
- declarations
- lib
- config
- errors
- performance
- schemas
- test
- __snapshots__
- configCases/performance
- async-chunk-waterfalls-clean
- async-chunk-waterfalls-error
- async-chunk-waterfalls-no-hints
- async-chunk-waterfalls-stats
- async-chunk-waterfalls
- embedded-source-maps-development
- embedded-source-maps-error
- embedded-source-maps-eval
- embedded-source-maps-no-hints
- embedded-source-maps-separate
- embedded-source-maps-stats
- embedded-source-maps
- inlined-assets-clean
- inlined-assets-error
- inlined-assets-no-hints
- inlined-assets-stats
- inlined-assets
- top-level-this-class
- top-level-this-commonjs
- top-level-this-error
- top-level-this-no-hints
- top-level-this-stats
- top-level-this
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3287 | 3287 | | |
3288 | 3288 | | |
3289 | 3289 | | |
| 3290 | + | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
3290 | 3295 | | |
3291 | 3296 | | |
3292 | 3297 | | |
| |||
3322 | 3327 | | |
3323 | 3328 | | |
3324 | 3329 | | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
3325 | 3335 | | |
3326 | 3336 | | |
3327 | 3337 | | |
| |||
3341 | 3351 | | |
3342 | 3352 | | |
3343 | 3353 | | |
| 3354 | + | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
3344 | 3359 | | |
3345 | 3360 | | |
3346 | 3361 | | |
| |||
3399 | 3414 | | |
3400 | 3415 | | |
3401 | 3416 | | |
| 3417 | + | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
3402 | 3422 | | |
3403 | 3423 | | |
3404 | 3424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
978 | 978 | | |
979 | 979 | | |
980 | 980 | | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
981 | 987 | | |
982 | 988 | | |
983 | 989 | | |
| |||
1014 | 1020 | | |
1015 | 1021 | | |
1016 | 1022 | | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
1017 | 1029 | | |
1018 | 1030 | | |
1019 | 1031 | | |
| |||
1032 | 1044 | | |
1033 | 1045 | | |
1034 | 1046 | | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
1035 | 1059 | | |
1036 | 1060 | | |
1037 | 1061 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2418 | 2418 | | |
2419 | 2419 | | |
2420 | 2420 | | |
| 2421 | + | |
2421 | 2422 | | |
2422 | 2423 | | |
2423 | 2424 | | |
| |||
2426 | 2427 | | |
2427 | 2428 | | |
2428 | 2429 | | |
| 2430 | + | |
2429 | 2431 | | |
2430 | 2432 | | |
2431 | 2433 | | |
2432 | 2434 | | |
| 2435 | + | |
2433 | 2436 | | |
2434 | 2437 | | |
2435 | 2438 | | |
| |||
2438 | 2441 | | |
2439 | 2442 | | |
2440 | 2443 | | |
| 2444 | + | |
2441 | 2445 | | |
2442 | 2446 | | |
2443 | 2447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
0 commit comments