Skip to content

Commit de48b9c

Browse files
fix: do not annotate the call that starts an entry
An entry runs by contract, not because something imports it, so a minifier that drops the startup call leaves the entry unexecuted — `all-combined` built nine cases whose bundles then registered no tests at all. Side-effect freedom says an importer may skip a module; it does not say the entry may never run. Refs #17121
1 parent 7f7ce88 commit de48b9c

6 files changed

Lines changed: 1 addition & 130 deletions

File tree

‎lib/javascript/StartupHelpers.js‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,12 @@ module.exports.generateEntryStartup = (
103103
)}`
104104
];
105105

106-
/** @type {Map<ModuleId, string>} entry module id -> its side-effects annotation */
107-
const pureByModuleId = new Map();
108-
// `__webpack_exec__` assigns `entryModuleId` on the way in, which the annotation
109-
// would license a minifier to drop along with the call.
110-
const canAnnotate = !chunkGraph
111-
.getTreeRuntimeRequirements(chunk)
112-
.has(RuntimeGlobals.entryModuleId);
113-
114106
/**
115107
* Returns fn to execute.
116108
* @param {ModuleId} id id
117109
* @returns {string} fn to execute
118110
*/
119-
const runModule = (id) =>
120-
`${pureByModuleId.get(id) || ""}__webpack_exec__(${JSON.stringify(id)})`;
111+
const runModule = (id) => `__webpack_exec__(${JSON.stringify(id)})`;
121112
/**
122113
* Output combination.
123114
* @param {Chunks} chunks chunks
@@ -159,15 +150,6 @@ module.exports.generateEntryStartup = (
159150
/** @type {Entrypoint} */
160151
(entrypoint).getRuntimeChunk();
161152
const moduleId = /** @type {ModuleId} */ (chunkGraph.getModuleId(module));
162-
if (canAnnotate) {
163-
pureByModuleId.set(
164-
moduleId,
165-
runtimeTemplate.moduleSideEffectsAnnotation(
166-
module,
167-
chunkGraph.moduleGraph
168-
)
169-
);
170-
}
171153
const chunks = getAllChunks(
172154
/** @type {Entrypoint} */
173155
(entrypoint),

‎test/configCases/side-effects/pure-entry-startup/index.js‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎test/configCases/side-effects/pure-entry-startup/lib.js‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎test/configCases/side-effects/pure-entry-startup/pure-cjs.js‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎test/configCases/side-effects/pure-entry-startup/refs-entry.js‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎test/configCases/side-effects/pure-entry-startup/webpack.config.js‎

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)