Skip to content

Commit

Permalink
test(mangler): failing test for exported top level variables
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Dec 16, 2024
1 parent 10a86b9 commit 41aa4a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/oxc_minifier/tests/mangler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ fn mangler() {
"import { x } from 's'; export { x }",
"function _ (exports) { Object.defineProperty(exports, '__esModule', { value: true }) }",
];
let top_level_cases = ["function foo(a) {a}"];
let top_level_cases = [
"function foo(a) {a}",
"export function foo() {}; foo()",
"export default function foo() {}; foo()",
"export const foo = 1; foo",
"const foo = 1; foo; export { foo }",
];

let mut snapshot = String::new();
cases.into_iter().fold(&mut snapshot, |w, case| {
Expand Down
21 changes: 21 additions & 0 deletions crates/oxc_minifier/tests/mangler/snapshots/mangler.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,24 @@ function foo(a) {a}
function a(b) {
b;
}

export function foo() {}; foo()
function a() {}
;
a();
export { a as foo };

export default function foo() {}; foo()
export default function a() {}
;
a();

export const foo = 1; foo
export const a = 1;
a;
export { a as foo };

const foo = 1; foo; export { foo }
const a = 1;
a;
export { a as foo };

0 comments on commit 41aa4a0

Please sign in to comment.