Open privatenumber opened 1 year ago
Tree shaking is supposed to be an optimization that doesn't affect the behavior of the build. In particular, the build should fail if some part of the module graph contains a syntax error. So esbuild deliberately crawls the entire module graph before tree shaking begins.
I appreciate your perspective on this! I believe it could be a missed chance to get more out of sideEffect: false
and further optimize build performance.
Wouldn't someone deliberately writing an empty import/export from a side-effect free package suffice as a signal to disregard the statement?
I do understand that type imports are treated as annotations, but if having type
is sufficient to drop the statement and not follow the import, it seems there's enough of a signal here as well. What do you think?
When re-exporting nothing from a package that has sideEffects disabled, I would expect esbuild to discard the export completely. However, it seems to try to resolve all paths within the package unnecessarily.
I think this has a non-trivial performance impact on WASM.
Reproduction
https://stackblitz.com/edit/stackblitz-starters-b1bwlb?file=index.mjs