You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use treeshaking, (aka import { Vector2 } from 'three';) with esbuild, but it isn't working, instead it's pulling in all of three.module.js.
Reproduction steps
Create a file that imports only Vector2 from three
Attempt to bundle it with esbuild: npx esbuild index.js --bundle --outfile=bundle.js
Notice that the bundle size it much larger than it should be
Following the discussion it seems the "importing Vector2 case" was discussed extensively and the conclusion was:
So how about this, if we all agree that using 'three' without a renderer (an ES module library) is a secondary or even unsupported use case, then I think we can close this issue.
The solution to change the import from 'three' to 'three/src/Three.js' fixed tree-shaking for me....
I would be cautious with this workaround – addons like loaders and controls also import from 'three', so it's easy to end up with multiple copies of three.js in your codebase.
Support for the missing tree-shaking features in ESBuild can be tracked in the issue below. As @Mugen87 mentions, this isn't something we plan to change in the meantime.
Description
I'm trying to use treeshaking, (aka
import { Vector2 } from 'three';
) with esbuild, but it isn't working, instead it's pulling in all ofthree.module.js
.Reproduction steps
Vector2
fromthree
npx esbuild index.js --bundle --outfile=bundle.js
Code
I made a small reproduction repo: https://github.com/TesseractCat/three-esbuild-tree-shaking-broken
Live example
N/A
Screenshots
No response
Version
^0.151.3
Device
Desktop
Browser
Chrome, Firefox
OS
Windows, Linux
The text was updated successfully, but these errors were encountered: