From e5c4ae0fe09e72c1ebfa75665dc24aeb8543690a Mon Sep 17 00:00:00 2001 From: kzc Date: Sun, 17 Dec 2017 01:38:58 -0500 Subject: [PATCH] workaround for `compress` of `export default` anonymous functions --- lib/compress.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/compress.js b/lib/compress.js index 4065c543..e3bfa938 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -409,6 +409,7 @@ merge(Compressor.prototype, { } } if (node instanceof AST_DefClass || node instanceof AST_Defun) { + if (!node.name) return; node.inlined = false; var d = node.name.definition(); if (compressor.exposed(d) || safe_to_read(d)) { @@ -2581,6 +2582,7 @@ merge(Compressor.prototype, { if (node instanceof AST_Defun || node instanceof AST_DefClass) { var in_export = tw.parent() instanceof AST_Export; if (in_export || !drop_funcs && scope === self) { + if (!node.name) return; var node_def = node.name.definition(); if (node_def.global && !(node_def.id in in_use_ids)) { in_use_ids[node_def.id] = true; @@ -2666,6 +2668,7 @@ merge(Compressor.prototype, { if (node.name && (!compressor.option("keep_classnames") && node instanceof AST_ClassExpression || !compressor.option("keep_fnames") && node instanceof AST_Function)) { + if (!node.name) return; var def = node.name.definition(); // any declarations with same name will overshadow // name of this anonymous function and can therefore @@ -2701,6 +2704,7 @@ merge(Compressor.prototype, { } } if ((node instanceof AST_Defun || node instanceof AST_DefClass) && node !== self) { + if (!node.name) return; var def = node.name.definition(); var keep = (def.id in in_use_ids) || !drop_funcs && def.global; if (!keep) {