Question on tree shaking dependencies
- Dominant language
- Go
- Stars
- 40.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.