fix(es/minifier): Mark usage in TaggedTpl as ref (#8975)

**Related issue:**

 - Closes #8974
This commit is contained in:
Donny/강동윤 2024-05-24 14:11:00 +09:00 committed by GitHub
parent a15474c331
commit a753c8d191
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 84 additions and 5 deletions

View File

@ -0,0 +1,47 @@
{
"defaults": true,
"arguments": false,
"arrows": true,
"booleans": true,
"booleans_as_integers": false,
"collapse_vars": true,
"comparisons": true,
"computed_props": true,
"conditionals": true,
"dead_code": true,
"directives": true,
"drop_console": false,
"drop_debugger": true,
"evaluate": true,
"expression": false,
"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": false,
"side_effects": true,
"switches": true,
"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,
"const_to_let": true,
"pristine_globals": true
}

View File

@ -0,0 +1,13 @@
const one = {
kind: "Document",
definitions: [],
loc: {}
};
const two = {
kind: "Document",
definitions: one.definitions,
};
const three = a`${one}`;
export { }

View File

@ -0,0 +1,7 @@
const one = {
kind: "Document",
definitions: [],
loc: {}
};
one.definitions, a`${one}`;
export { };

View File

@ -1168,12 +1168,24 @@ where
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
fn visit_tagged_tpl(&mut self, n: &TaggedTpl) {
let ctx = Ctx {
is_id_ref: false,
..self.ctx
};
{
let ctx = Ctx {
is_id_ref: false,
..self.ctx
};
n.visit_children_with(&mut *self.with_ctx(ctx))
n.tag.visit_with(&mut *self.with_ctx(ctx));
}
{
let ctx = Ctx {
is_id_ref: true,
..self.ctx
};
// Bypass visit_tpl
n.tpl.visit_children_with(&mut *self.with_ctx(ctx))
}
}
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]