Skip to content

Commit d681785

Browse files
authoredDec 29, 2023
fix(es/minifier): Add WeakRef as a safe global reference (#8458)
**Description:** I was trying to remove references to Weak Ref from minified code and despite the expression not being used, it was still included. E.g. ``` var x = WeakRef; ``` with ``` { "minify": true, "jsc": { "minify": { "compress": { "pure_getters": true, "unused": true }, "mangle": true } } } ``` outputs ``` WeakRef; ``` but when I use something on this list e.g. parseFloat, it gets cleaned up and outputs empty string. btw - I tried different options for pure_getters that I assumed would allow me to say WeakRef as a getter was pure, but it had no effect. WeakRef getter is as safe to remove as the other items on this list and has no effect in accessing it.
1 parent 4229e7b commit d681785

File tree

1 file changed

+1
-0
lines changed
  • crates/swc_ecma_usage_analyzer/src

1 file changed

+1
-0
lines changed
 

‎crates/swc_ecma_usage_analyzer/src/util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub fn is_global_var_with_pure_property_access(s: &str) -> bool {
3939
| "NaN"
4040
| "Symbol"
4141
| "Promise"
42+
| "WeakRef"
4243
)
4344
}
4445

0 commit comments

Comments
 (0)
Please sign in to comment.