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] Untransformed exports in conditional branch #1771

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

[plugin-commonjs] Untransformed exports in conditional branch #1771

jaskp opened this issue Sep 23, 2024 · 2 comments

Comments

@jaskp
Copy link

jaskp commented Sep 23, 2024

Expected Behavior

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

Actual Behavior

A reachable 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
@jaskp jaskp changed the title plugin-commonjs broken by || false [plugin-commonjs] Untransformed exports in conditional branch Oct 23, 2024
@jaskp
Copy link
Author

jaskp commented Oct 23, 2024

Would it be possible to address this? @shellscape should I rather post this into the main Rollup repo?

@shellscape
Copy link
Collaborator

Thanks for the issue, but this will likely need community contribution to resolve. We're very short on maintainers at the moment.

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

2 participants