Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define replaces property access incorrectly #7598

Closed
sapphi-red opened this issue Dec 3, 2024 · 4 comments · Fixed by #7640
Closed

define replaces property access incorrectly #7598

sapphi-red opened this issue Dec 3, 2024 · 4 comments · Fixed by #7640
Assignees
Labels
C-bug Category - Bug

Comments

@sapphi-red
Copy link
Contributor

I made a test case as that was easier than explaining in text: #7597
esbuild try

@IWANABETHATGUY
Copy link
Contributor

IWANABETHATGUY commented Dec 4, 2024

I don't think oxc define output is wrong,
esbuild output

var define_OBJ_default = { process: { env: { SOMEVAR: "foo" } } };
console.log(define_OBJ_default.process.env.SOMEVAR);

oxc output

console.log('foo');\n

@IWANABETHATGUY
Copy link
Contributor

Ok, the output looks like a constant eval, but actually is a but, lol.

@sapphi-red
Copy link
Contributor Author

Ah, sorry the esbuild try link should be this one (changed --define:process.env.SOMEVAR="\"foo\"" to --define:process.env.SOMEVAR="\"SOMEVAR\"").

oxc replaces __OBJ__.process.env.SOMEVAR to "SOMEVAR" (should be "foo").

@sapphi-red
Copy link
Contributor Author

Slightly related: I noticed the reference behavior difference (#7641).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category - Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants