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
Original code:
import { DEV } from "./constants"; function reportError() { if (DEV) { const message = "some useful message" throw new Error(message) } else { throw new Error("ERROR_CODE x2242"); } } export { reportError };
bundled & minified output (--minify --bundle --format=esm):
--minify --bundle --format=esm
function E(){if(!1){let r="some useful message";throw new Error(r)}else throw new Error("ERROR_CODE x2242")}export{E as reportError};
expected output:
function E(){throw new Error("ERROR_CODE x2242")}export{E as reportError};
Works perfectly when DEV boolean is defined in the same file
DEV
const DEV = false function reportError() { if (DEV) { const message = "some useful message" throw new Error(message) } else { throw new Error("ERROR_CODE x2242"); } } export { reportError };
or when there's no variable declaration inside if (DEV) condition
if (DEV)
import { DEV } from "./constants"; function reportError() { if (DEV) { throw new Error("some useful message") } else { throw new Error("ERROR_CODE x2242"); } } export { reportError };
minimal repro link https://esbuild.github.io/try/#YgAwLjI0LjAALS1taW5pZnkgLS1idW5kbGUgLS1mb3JtYXQ9ZXNtAGUAZW50cnkuanMAaW1wb3J0IHsgREVWIH0gZnJvbSAiLi9jb25zdGFudHMiOwoKZnVuY3Rpb24gcmVwb3J0RXJyb3IoKSB7CiAgaWYgKERFVikgewogICAgIGNvbnN0IG1lc3NhZ2UgPSAic29tZSB1c2VmdWwgbWVzc2FnZSIKICAgICB0aHJvdyBuZXcgRXJyb3IobWVzc2FnZSkKICB9IGVsc2UgewogICAgdGhyb3cgbmV3IEVycm9yKCJFUlJPUl9DT0RFIHgyMjQyIik7CiAgfQp9CgpleHBvcnQgeyByZXBvcnRFcnJvciB9OwoAAGNvbnN0YW50cwBleHBvcnQgY29uc3QgREVWID0gZmFsc2U7
or try to build @sveltejs for browser.
browser
Thanks @evanw 🙏
The text was updated successfully, but these errors were encountered:
esm-env
No branches or pull requests
Original code:
bundled & minified output (
--minify --bundle --format=esm
):expected output:
Works perfectly when
DEV
boolean is defined in the same fileor when there's no variable declaration inside
if (DEV)
conditionminimal repro link https://esbuild.github.io/try/#YgAwLjI0LjAALS1taW5pZnkgLS1idW5kbGUgLS1mb3JtYXQ9ZXNtAGUAZW50cnkuanMAaW1wb3J0IHsgREVWIH0gZnJvbSAiLi9jb25zdGFudHMiOwoKZnVuY3Rpb24gcmVwb3J0RXJyb3IoKSB7CiAgaWYgKERFVikgewogICAgIGNvbnN0IG1lc3NhZ2UgPSAic29tZSB1c2VmdWwgbWVzc2FnZSIKICAgICB0aHJvdyBuZXcgRXJyb3IobWVzc2FnZSkKICB9IGVsc2UgewogICAgdGhyb3cgbmV3IEVycm9yKCJFUlJPUl9DT0RFIHgyMjQyIik7CiAgfQp9CgpleHBvcnQgeyByZXBvcnRFcnJvciB9OwoAAGNvbnN0YW50cwBleHBvcnQgY29uc3QgREVWID0gZmFsc2U7
or try to build @sveltejs for
browser
.Thanks @evanw 🙏
The text was updated successfully, but these errors were encountered: