Skip to content
New issue

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

[Bug]: rules_esbuild does not tree-shake using sideEffects in package.json #187

Open
pyrocat101 opened this issue Feb 5, 2024 · 0 comments
Labels
bug Something isn't working untriaged Requires traige

Comments

@pyrocat101
Copy link

pyrocat101 commented Feb 5, 2024

What happened?

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

Language(s) and/or frameworks involved:

How to reproduce

Repro: https://github.com/pyrocat101/esbuild_side_effects_repro

# 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

Any other information?

No response

@pyrocat101 pyrocat101 added the bug Something isn't working label Feb 5, 2024
@github-actions github-actions bot added the untriaged Requires traige label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Requires traige
Projects
Status: No status
Development

No branches or pull requests

1 participant