We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
// index.js let value; if (process.env.USE === 'foo') { value = require('./foo'); } else { value = require('./bar'); } console.log(value); // foo.js module.exports = 'foo'; // bar.js module.exports = 'bar';
Command:
esbuild --bundle index.js '--define:process.env.USE=null' --format=esm
foo.js not to be bundled, since null === 'foo' should always evaluate to false.
foo.js
null === 'foo'
false
// ...[omitted] // index.js var value; if (null === "foo") { value = require_foo(); } else { value = require_bar(); } console.log(value);
However, if the following command is used instead:
esbuild --bundle index.js '--define:process.env.USE="null"' --format=esm
then the constant folding is correctly applied to the if conditions as well as the branch block.
// ...[omitted] // index.js var value; if (false) { value = null; } else { value = require_bar(); } console.log(value);
The text was updated successfully, but these errors were encountered:
bfe3ead
No branches or pull requests
Repro
Command:
esbuild --bundle index.js '--define:process.env.USE=null' --format=esm
Expected output
foo.js
not to be bundled, sincenull === 'foo'
should always evaluate tofalse
.Actual output
However, if the following command is used instead:
esbuild --bundle index.js '--define:process.env.USE="null"' --format=esm
then the constant folding is correctly applied to the if conditions as well as the branch block.
The text was updated successfully, but these errors were encountered: