Skip to content

Commit

Permalink
fix(oxc_transform): oxc dot define is postfix of some MemberExpr (#7640)
Browse files Browse the repository at this point in the history
Closed #7598
  • Loading branch information
IWANABETHATGUY authored Dec 4, 2024
1 parent 0ce7ce7 commit 64f92e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ impl<'a> ReplaceGlobalDefines<'a> {
};
}

true
current_part_member_expression.is_none()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ fn dot_with_overlap() {
test("import.meta.env.NODE_ENV", "import.meta.env.NODE_ENV", config.clone());
}

#[test]
fn dot_define_is_member_expr_postfix() {
let config = ReplaceGlobalDefinesConfig::new(&[
("__OBJ__", r#"{"process":{"env":{"SOMEVAR":"foo"}}}"#),
("process.env.SOMEVAR", "\"SOMEVAR\""),
])
.unwrap();
test(
"console.log(__OBJ__.process.env.SOMEVAR)",
"console.log({ 'process': { 'env': { 'SOMEVAR': 'foo' } } }.process.env.SOMEVAR);\n",
config.clone(),
);
}

#[test]
fn dot_nested() {
let config = ReplaceGlobalDefinesConfig::new(&[("process", "production")]).unwrap();
Expand Down

0 comments on commit 64f92e9

Please sign in to comment.