8000 `TopLevelBindingCollector` of minifier is wrong · Issue #4561 · swc-project/swc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
TopLevelBindingCollector of minifier is wrong #4561
Open
@kdy1

Description

@kdy1

Describe the bug

metadata module is currently noop, but the name is misleading

5A81
impl TopLevelBindingCollector {
fn add(&mut self, id: Id) {
if id.1 != self.top_level_ctxt {
return;
}
self.bindings.push(id);
}
}
impl Visit for TopLevelBindingCollector {
noop_visit_type!();
fn visit_class_decl(&mut self, v: &ClassDecl) {
self.add(v.ident.to_id());
}
fn visit_fn_decl(&mut self, v: &FnDecl) {
self.add(v.ident.to_id());
}
fn visit_function(&mut self, _: &Function) {}
fn visit_var_decl(&mut self, v: &VarDecl) {
v.visit_children_with(self);
let ids: Vec<Id> = find_ids(&v.decls);
for id in ids {
self.add(id)
}
}
}

Input code

No response

Config

No response

Playground link

No response

Expected behavior

We may provide collect_top_level_decls from swc_ecma_utils

Actual behavior

No response

Version

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0