Skip to content

Commit ad619be

Browse files
fix(javascript): give back as written an event handler printed as nothing
The plugin's entry points minify a handler as a function body and hand the text back when the function is dropped whole or no code is asked for; jsMinify answered an empty string or undefined there, failing the jsMinify tests #22936 added on main.
1 parent 5436153 commit ad619be

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Give back as written an event handler the JavaScript minifier prints as nothing.

‎lib/javascript/jsMinify.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,12 @@ const jsMinify = async (
193193
const result = await minifier.minify({ [file]: code }, minifyOptions);
194194

195195
return {
196-
code: /** @type {string} */ (result.code),
196+
// A handler printed as nothing (dropped whole, or no code asked for) is
197+
// given back as written, as the plugin's own entry points answer.
198+
code:
199+
as === "event-handler" && !result.code
200+
? code
201+
: /** @type {string} */ (result.code),
197202
map: result.map ? result.map : undefined,
198203
extractedComments: extracted
199204
};

0 commit comments

Comments
 (0)