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

plugin-commonjs broken by || false #1771

Open
jaskp opened this issue Sep 23, 2024 · 0 comments
Open

plugin-commonjs broken by || false #1771

jaskp opened this issue Sep 23, 2024 · 0 comments

Comments

@jaskp
Copy link

jaskp commented Sep 23, 2024

Expected Behavior

All CJS exports (i.e. exports.foo = bar) are removed.

Actual Behavior

A CJS export remains in the true branch:

/* dist/index.mjs */
if (globalThis.crypto || false) {
  // 👇
  exports.getRandomValue = () =>
    globalThis.crypto.getRandomValues(new Uint8Array(1))[0];
} else {
  lib.getRandomValue = () => {
    throw Error();
  };
}

Additional Information

This happens when appending || false to the condition in the if statement.

@jaskp jaskp changed the title plugin-commonjs misses export in conditional statement affected by plugin-replace plugin-commonjs broken by || false Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant