You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actual
The bar variable, which is unused in the code, is not being tree-shaken (dropped) as expected. This increases the bundle size unnecessarily.
Expected Output
Only the foo export should be retained in the final bundle because bar is not used in the importing module. The desired output should look like:
Context
The issue arises even though esbuild is set up with splitting and bundle optimizations enabled. The expectation is that unused exports like bar would be eliminated.
When using a dynamic import, unused symbols are not being tree-shaken (dropped) from the output bundle.
Input Code Example
Observed Output
Actual
The
bar
variable, which is unused in the code, is not being tree-shaken (dropped) as expected. This increases the bundle size unnecessarily.Expected Output
Only the
foo
export should be retained in the final bundle becausebar
is not used in the importing module. The desired output should look like:Context
The issue arises even though
esbuild
is set up with splitting and bundle optimizations enabled. The expectation is that unused exports likebar
would be eliminated.Reproduction Link
The behavior can be reproduced using the REPL: https://esbuild.github.io/try/#YgAwLjI0LjAALS1idW5kbGUgLS1mb3JtYXQ9ZXNtIC0tc3BsaXR0aW5nIC0tb3V0ZGlyPSIvIiAAZQBlbnRyeS5qcwBjb25zdCB7IGZvbyB9ID0gYXdhaXQgaW1wb3J0KCcuL2RlcC5qcycpOwpjb25zb2xlLmxvZyhmb28pAABkZXAuanMAZXhwb3J0IGNvbnN0IGZvbyA9ICJmb28iOwpleHBvcnQgY29uc3QgYmFyID0gImJhciI7
The text was updated successfully, but these errors were encountered: