mirror of
https://github.com/swc-project/swc.git
synced 2024-11-26 20:36:17 +03:00
fix(es/minifier): Fix inlining of uninitialized variables (#4292)
This commit is contained in:
parent
1fb456c630
commit
b990b19ed1
68
crates/swc/tests/fixture/issues-4xxx/issue-4276/input/.swcrc
Normal file
68
crates/swc/tests/fixture/issues-4xxx/issue-4276/input/.swcrc
Normal file
@ -0,0 +1,68 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "ecmascript",
|
||||
"jsx": false
|
||||
},
|
||||
"target": "es2015",
|
||||
"loose": false,
|
||||
"minify": {
|
||||
"compress": {
|
||||
"arguments": false,
|
||||
"arrows": true,
|
||||
"booleans": true,
|
||||
"booleans_as_integers": false,
|
||||
"collapse_vars": true,
|
||||
"comparisons": true,
|
||||
"computed_props": false,
|
||||
"conditionals": false,
|
||||
"dead_code": false,
|
||||
"directives": false,
|
||||
"drop_console": false,
|
||||
"drop_debugger": true,
|
||||
"evaluate": true,
|
||||
"expression": true,
|
||||
"hoist_funs": false,
|
||||
"hoist_props": true,
|
||||
"hoist_vars": false,
|
||||
"if_return": true,
|
||||
"join_vars": true,
|
||||
"keep_classnames": false,
|
||||
"keep_fargs": true,
|
||||
"keep_fnames": false,
|
||||
"keep_infinity": false,
|
||||
"loops": true,
|
||||
"negate_iife": true,
|
||||
"properties": true,
|
||||
"reduce_funcs": false,
|
||||
"reduce_vars": true,
|
||||
"side_effects": true,
|
||||
"switches": false,
|
||||
"typeofs": true,
|
||||
"unsafe": false,
|
||||
"unsafe_arrows": false,
|
||||
"unsafe_comps": false,
|
||||
"unsafe_Function": false,
|
||||
"unsafe_math": false,
|
||||
"unsafe_symbols": false,
|
||||
"unsafe_methods": false,
|
||||
"unsafe_proto": false,
|
||||
"unsafe_regexp": false,
|
||||
"unsafe_undefined": false,
|
||||
"unused": true
|
||||
},
|
||||
"mangle": {
|
||||
"toplevel": true,
|
||||
"keep_classnames": false,
|
||||
"keep_fnames": false,
|
||||
"keep_private_props": false,
|
||||
"ie8": false,
|
||||
"safari10": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "es6"
|
||||
},
|
||||
"minify": true
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
const foo = 'foo-';
|
||||
|
||||
console.log(foo)
|
||||
const A = `${foo}bar`;
|
||||
const B = `${foo}bar2`;
|
||||
|
||||
console.log("test", foo, A, B)
|
@ -0,0 +1 @@
|
||||
const a="foo-";console.log(a);const b=`${a}bar`,c=`${a}bar2`;console.log("test",a,b,c)
|
@ -129,13 +129,19 @@ where
|
||||
.data
|
||||
.vars
|
||||
.get(&i.to_id())
|
||||
.map(|v| v.assign_count == 0 && !v.declared_as_fn_param)
|
||||
.map(|v| {
|
||||
v.declared
|
||||
&& !v.var_initialized
|
||||
&& !v.cond_init
|
||||
&& v.assign_count == 0
|
||||
&& !v.declared_as_fn_param
|
||||
})
|
||||
.unwrap_or(false)
|
||||
{
|
||||
self.changed = true;
|
||||
tracing::debug!(
|
||||
"strings: Converting a reference ({}{:?}) into `undefined` (in string \
|
||||
context)",
|
||||
"strings: Converting an unresolved reference ({}{:?}) into `undefined` \
|
||||
(in string context)",
|
||||
i.sym,
|
||||
i.span.ctxt
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user