Libraries such as lodash-es relies on "sideEffects": false field in their package.json to property eliminate (tree-shake) unused utilities in the resulting bundle. But rules_esbuild does not seem to respect this field, resulting in large bundles when lodash-es is a dependency.
Disabling Bazel sandbox plugin does not resolve the issue (although there is a very noticeable performance difference).
See "How to reproduce" section for a minimal repro.
Version
Development (host) and target OS/architectures:
Output of bazel --version: aspect 5.8.19
Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file: rules_esbuild 0.18.0, rules_js 1.37.0
# Produces a large bundle file, where every operator in lodash-es is included in the resulting bundle.
bazel build //:bundle
# Produces a small bundle where only the implementation of used utility is included.
pnpm install
npx esbuild --bundle --format=esm --target=node18 index.js
What happened?
Libraries such as
lodash-es
relies on"sideEffects": false
field in theirpackage.json
to property eliminate (tree-shake) unused utilities in the resulting bundle. Butrules_esbuild
does not seem to respect this field, resulting in large bundles whenlodash-es
is a dependency.Disabling Bazel sandbox plugin does not resolve the issue (although there is a very noticeable performance difference).
See "How to reproduce" section for a minimal repro.
Version
Development (host) and target OS/architectures:
Output of
bazel --version
: aspect 5.8.19Version of the Aspect rules, or other relevant rules from your
WORKSPACE
orMODULE.bazel
file: rules_esbuild 0.18.0, rules_js 1.37.0Language(s) and/or frameworks involved:
How to reproduce
Repro: https://github.com/pyrocat101/esbuild_side_effects_repro
Any other information?
No response