Skip to content

Commit

Permalink
Partial revert
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jul 18, 2024
1 parent fb3eabe commit ef5dcfb
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class A {
constructor(o = {}){
constructor(o: AOptions = {}){
const { a = defaultA, c } = o;
this.#a = a;
this.#c = c;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function A() {
return "a";
}
const b = "b";
export function c() {
return <A.b />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function A() {
return "a";
}
export function c() {
return <A.b />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function A() {
return "a";
}
const b = "b";
const c = "c";
export function d() {
return <A.b.c />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function A() {
return "a";
}
export function d() {
return <A.b.c />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function A() {
return "a";
}
const b = "b";
const c = "c";
export function d() {
return <A {...b}>{c}</A>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function A() {
return "a";
}
const b = "b";
const c = "c";
export function d() {
return <A {...b}>{c}</A>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function A() {
return "a";
}
const b = "b";
const c = "c";
export function d() {
return <A val={b}>{c}</A>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function A() {
return "a";
}
const b = "b";
const c = "c";
export function d() {
return <A val={b}>{c}</A>;
}
17 changes: 17 additions & 0 deletions crates/swc_ecma_transforms_optimization/tests/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ fn dce_repeated(input: PathBuf) {
);
}

#[testing::fixture("tests/dce-jsx/**/input.js")]
fn dce_jsx(input: PathBuf) {
let output = input.with_file_name("output.js");

test_fixture(
Syntax::Es(EsSyntax {
decorators: true,
jsx: true,
..Default::default()
}),
&|t| chain!(remover(t), dce(Default::default(), Mark::new())),
&input,
&output,
Default::default(),
);
}

#[testing::fixture("tests/expr-simplifier/**/input.js")]
fn expr(input: PathBuf) {
let output = input.with_file_name("output.js");
Expand Down
18 changes: 18 additions & 0 deletions crates/swc_ecma_usage_analyzer/src/analyzer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,24 @@ where
self.declare_decl(&n.local, true, None, false);
}

#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
fn visit_jsx_element_name(&mut self, n: &JSXElementName) {
let ctx = Ctx {
in_pat_of_var_decl: false,
in_pat_of_param: false,
in_catch_param: false,
var_decl_kind_of_pat: None,
in_pat_of_var_decl_with_init: false,
..self.ctx
};

n.visit_children_with(&mut *self.with_ctx(ctx));

if let JSXElementName::Ident(i) = n {
self.with_ctx(ctx).report_usage(i);
}
}

#[cfg_attr(feature = "debug", tracing::instrument(skip(self, e)))]
fn visit_member_expr(&mut self, e: &MemberExpr) {
{
Expand Down

0 comments on commit ef5dcfb

Please sign in to comment.