File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37832,11 +37832,13 @@ const createCompressHelpers = (modules) => {
3783237832 if (undefinedValue) return undefinedValue;
3783337833 if (!isSymbolRefNode(node)) return false;
3783437834 let fixed = node.definition.fixed;
37835- // terser reads only a value stored as a node, not one read lazily.
37835+ // terser reads only a value stored as a node, not one read lazily; an
37836+ // exposed variable stays declared, so `void 0` saves nothing there.
3783637837 if (
3783737838 !isSyntaxNode(fixed) &&
3783837839 modules.improvements !== undefined &&
37839- modules.improvements.enabled
37840+ modules.improvements.enabled &&
37841+ !compressor.exposed(node.definition)
3784037842 ) {
3784137843 fixed = ast.fixedValue(node);
3784237844 }
Original file line number Diff line number Diff line change @@ -1165,6 +1165,10 @@ const IMPROVED_CASES = [
11651165// of its function's own, or the call passes, keeps or constructs something.
11661166/** @type {[string, string][]} */
11671167const KEPT_CASES = [
1168+ [
1169+ "optional reads of a global `const` known `undefined`, which stays declared",
1170+ "const obj = void 0; function f(x) { console.log(x); } f(obj?.a); f(obj?.a);"
1171+ ],
11681172 [
11691173 "a `RegExp` call where the program assigns the global",
11701174 'RegExp = function (pattern) { return "own " + pattern; }; console.log(RegExp("a"));'
You can’t perform that action at this time.
0 commit comments