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

Tree shaking differs between splitting and no splitting #3704

Open
taylorzane opened this issue Mar 19, 2024 · 0 comments
Open

Tree shaking differs between splitting and no splitting #3704

taylorzane opened this issue Mar 19, 2024 · 0 comments

Comments

@taylorzane
Copy link

Repro: https://github.com/taylorzane/esbuild-elkjs-bundle (includes bundle output and metafiles)

When using the following library (@unovis/ts) inside of an esbuild bundle, a number of modules that are imported by various components are not properly tree-shaken when code splitting is enabled. When code splitting is disabled, the modules are correctly discarded.

As far as I can tell this is primarily caused by the bare import in @unovis/ts/index.js that leads to the (one of many) following chain:

@unovis/ts/index.js => import-statement => @unovis/ts/components.js 
@unovis/ts/components.js => import-statement => @unovis/ts/components/graph/index.js
@unovis/ts/components/graph/index.js => import-statement => @unovis/ts/components/graph/modules/layout.js
@unovis/ts/components/graph/modules/layout.js => dynamic-import => elkjs/lib/elk.bundled.js

It's not immediately clear whether the underlying problem is with esbuild or the library, but the discrepancy between splitting/no splitting is odd.

esbuild: 0.20.2
@unovis/ts: 1.3.5
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

1 participant