Closed
Description
I've noticed a case where the constant folding isn't happening where I thought it should.
It works great in tertirary operators, however it doesn't seem to fold with constant if
conditions.
echo "if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-dom.production.min.js');
} else {
module.exports = require('./cjs/react-dom.development.js');
}" | esbuild --define:process.env.NODE_ENV=\"production\"
if (true) {
module.exports = require("./cjs/react-dom.production.min.js");
} else {
module.exports = require("./cjs/react-dom.development.js");
}
Looking at #371 it appears like that should be folded properly.
If I enable minification, it does do the proper foldinig.
echo "if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-dom.production.min.js');
} else {
module.exports = require('./cjs/react-dom.development.js');
}" | esbuild --define:process.env.NODE_ENV=\"production\" --minify
module.exports=require("./cjs/react-dom.production.min.js");
Metadata
Assignees
Labels
No labels