New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(es/minifier): Mark more expressions as pure #6204
Conversation
This reverts commit 0096b40ba775c2a85a059242dc32c7c6ad07c1ac.
@@ -301,7 +301,7 @@ where | |||
/// If a parameter is not used, we can ignore return value of the | |||
/// corresponding argument. | |||
pub(super) fn ignore_unused_args_of_iife(&mut self, e: &mut CallExpr) { | |||
if !self.options.unused { | |||
if !self.options.unused && !self.options.reduce_vars { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this because of
swc/crates/swc_ecma_minifier/tests/terser/compress/drop_unused/chained_3/input.js
Lines 1 to 8 in a0b0fd3
console.log( | |
(function (a, b) { | |
var c = a, | |
c = b; | |
b++; | |
return c; | |
})(1, 2) | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swc-bump:
- swc_ecma_minifier
@@ -1,2 +1,2 @@ | |||
//// [templateStringWithEmbeddedNewOperator.ts] | |||
"abc".concat(new String("Hi"), "def"); | |||
new String("Hi"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably isn't important with String
, but it's common for Map
/WeakMap
to be used. Are we eliminating built in constructors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we are not dropping String
. I think we should, though.
swc/crates/swc_ecma_minifier/src/compress/pure/misc.rs
Lines 1096 to 1100 in 7d5b544
Expr::New(NewExpr { callee, args, .. }) | |
if callee.is_one_of_global_ref_to( | |
&self.expr_ctx, | |
&["Map", "Set", "Array", "Object", "Boolean", "Number"], | |
) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated review comment generated by auto-rebase script
Description:
Related issue: