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

Question on tree shaking dependencies #3969

Open
wernst opened this issue Nov 8, 2024 · 2 comments
Open

Question on tree shaking dependencies #3969

wernst opened this issue Nov 8, 2024 · 2 comments

Comments

@wernst
Copy link

wernst commented Nov 8, 2024

This may be more a question than an issue, because esbuild is probably working as intended. I am bundling a file that imports a dependent library that uses bigint and exports that code. The code being imported and used does not use bigint. The target es2015 doenst support bigint and I am hoping that the dependency can be tree shaken so the bigint uses arent a part of the bundle. However esbuild does appear at some point to be pulling in bigint references and failing to build due to the target environment. Should I expect esbuild's tree shaking to help with this?

Reproduction: https://github.com/wernst/esbuild-tree-shake-reproduction

More specifics:
I am trying to bundle code to run in K6 (https://k6.io/), which uses a js engine written in Go goja (https://github.com/dop251/goja). From what i can tell, es2015 is a fairly safe target for this engine. However the code i am bundling has a dependency on remeda (https://github.com/remeda/remeda/), which uses bigint. According to their readme the library should play nicely with common bundler tree shaking implementations.

My current workaround is to patch remeda's package exports field to allow imports like import {doNothing} from 'remeda/doNothing with a wildcard entry point (https://nodejs.org/docs/latest-v18.x/api/packages.html#package-entry-points), but id rather not patch modules.

@wernst
Copy link
Author

wernst commented Nov 8, 2024

Related remeda issue: remeda/remeda#916

@XiSenao
Copy link

XiSenao commented Nov 21, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants