You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4448f8b
Browse filesBrowse the repository at this point in the historyBrowse files
feat(performance): add the analyzableBailouts hint (#21986)
* feat(performance): add the analyzableBailouts hint
A reference in ESM output that keeps webpack's runtime form was reported only
through `stats.optimizationBailout`, which nothing shows by default. The hint
names each reason and the modules it was recorded on, through the same
`hints` channel as the other checks.
The reasons a module records are stored beside its generated code and
reapplied when the cache restores it, so a warm build reports what a cold one
did. They are recorded on the module being generated, which is the one a
cached result belongs to.
* test(performance): cover a second bailout reason and pin the stats message
A worker loading its chunks through importScripts adds a second reason to the
warning case, so the ordering of reasons runs; the stats case asserts the
reason and module rather than the prefix. Trims the changeset to 80 characters.
* perf(performance): collect bailouts without allocating per module
The collector wrapped every module's code generation in a closure and handed
back a fresh array and tuple, an allocation per module on a hot path. Begin
and finish calls replace it, and the sink exists only once a reason is
recorded: over the many-modules-commonjs and lodash benchmark fixtures, one
pair of field writes per module and no allocation at all.
* fix(performance): hand every code generation its bailout reasons
A module generated once per runtime recorded a reason into the graph on the
first generation only, so the other runtime's cached result carried none. If
that runtime's entry is all the cache restores later, the hint loses the
reason. The graph stays deduplicated; each generation's sink records on its own.
* Report references in ESM output that keep webpack's runtime form, naming what stops each from being written as a literal 'import()' or 'new URL()' another bundler can follow (requires 'hints' to be enabled).
3443
+
* @since 5.111.0
3444
+
*/
3445
+
analyzableBailouts?: boolean;
3441
3446
/**
3442
3447
* Filter function to select assets that are checked.
MIT License http://www.opensource.org/licenses/mit-license.php
3
+
Author Alexander Akait @alexander-akait
4
+
*/
5
+
6
+
"use strict";
7
+
8
+
constWebpackError=require("./WebpackError");
9
+
10
+
/**
11
+
* @typedef {object} BailoutDetails
12
+
* @property {string} reason what keeps the runtime form, as the code generation recorded it
13
+
* @property {string[]} modules the modules it was recorded on, as many as are printed
14
+
* @property {number} count how many modules it was recorded on in all
* Creates an instance of AnalyzableBailoutsWarning.
20
+
* @param {BailoutDetails[]} bailouts the reasons found, the most frequent first
21
+
* @param {number} references how many module and reason pairs there are
22
+
*/
23
+
constructor(bailouts,references){
24
+
constlist=bailouts
25
+
.map((it)=>{
26
+
constmore=it.count-it.modules.length;
27
+
constnames=`${it.modules.join(", ")}${more>0 ? `, and ${more} more` : ""}`;
28
+
return`\n ${it.reason}\n ${names}`;
29
+
})
30
+
.join("");
31
+
32
+
super(
33
+
`analyzable ESM output: ${references}${references===1 ? "reference keeps" : "references keep"} the runtime form:${list}\nA bundler reading this output cannot follow such a reference without running webpack's runtime. Each reason names the setting that keeps it; changing that setting lets the reference be written as a literal import() or new URL().\nFor more info visit https://webpack.js.org/configuration/output/#outputmodule`
MIT License http://www.opensource.org/licenses/mit-license.php
Copy file name to clipboardExpand all lines: schemas/WebpackOptions.json
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5546,6 +5546,11 @@
5546
5546
"type": "boolean",
5547
5547
"added": "5.110.0"
5548
5548
},
5549
+
"analyzableBailouts": {
5550
+
"description": "Report references in ESM output that keep webpack's runtime form, naming what stops each from being written as a literal 'import()' or 'new URL()' another bundler can follow (requires 'hints' to be enabled).",
5551
+
"type": "boolean",
5552
+
"added": "5.111.0"
5553
+
},
5549
5554
"assetFilter": {
5550
5555
"description": "Filter function to select assets that are checked.",
0 commit comments