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
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.jsthat leads to the (one of many) following chain:It's not immediately clear whether the underlying problem is with esbuild or the library, but the discrepancy between splitting/no splitting is odd.