Skip to content

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

@jaskp

Description

@jaskp

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions