-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Build Size grows 5x with ThreeJs 0.150.0 #25595
Comments
@epreston Do you know why the issue is happening? |
You are building a library from a library in ES format. The expectation is the final application will do the tree-shaking. It may be as simple as linking cjs in 148 and actual esm in 150. What's the link to the project ? |
Im building a ts library with threejs and this is how i'm importing it. |
Yes. You've got a few issues. If your project was set up correctly you would expect a maximum of 411 KB for version 148. The maximum for 150 would be 415 KB based on those dependencies. You're getting something too small for your dependencies to be included on 148 (your 148 is not big enough to contain the required math components) and something too large on 150 for it to be three.js. I need to see what else you have in there. |
Link the project, I can run through it. |
This is actually a problem on our side, it can be replicated simply with: import { Scene } from 'three'
export { Scene } The tree-shaking issue was introduced in #24975, the I have a solution for this, will make a PR shortly. |
Yep, that's a "side effect" in a library marked with no side effects in the package.json. Just make it a normal member ? |
Deprecation warning cannot be logged then. |
Quick note: unit tests are not run against this (webglrenderers) on the pull request (as minimal as they are) because it's setup as webonly. This is not my choice. For sanity, you may want to to run the unit tests interactively in web mode to check things. |
@epreston @marcofugaro This is a demo project. Here you can see the difference in build sizes when we run "npm run build" for both versions. |
@marcofugaro If you make a PR just tag me. |
@rahulp-open I've already made a PR: #25599. |
@rahulp-open that test rig does not include what you are doing in the screenshots above. It simply creates a scene object and logs it to console at the moment. Are you done updating it ? |
Using what you have in that demo now, I'm seeing the following: release r148.0 dist/assets/index-f5119390.js 49.97 kB │ gzip: 14.47 kB release r150.1 dist/assets/index-a180db9d.js 406.75 kB │ gzip: 103.85 kB For reference, the project is creating a |
I've updated your project (see rahulp-open/threejs-issue-demo#1) to lock dependencies and build off of source instead of bundles. This allows for consistency between tests and the ability to experiment with the changes referenced above. Like Marco said above #25595 (comment), you can see how removing the release r150.1 (comment out block holding onto WebGLRenderer). dist/assets/index-d7410eb8.js 59.12 kB │ gzip: 17.89 kB At the start, that sounds great. The concern I have is it's not useful or practical in isolation. If you think about it for a few minutes, 59 kB for 80 lines of code is still extremely large. If you want to import and export the set of classes in your screenshots, it can be much smaller with different methods. Update the example for your specific use case or link the library project to get more complete feedback. |
Description
I installed threejs in a vite project ( vite ^4.0.0).
The threejs version was 0.150.0, the build size was 500kb.
After changing the the three js version to 0.148.0 the build size reduced to 100kb.
There is a huge difference in build size between these threejs versions. Whats causing this issue?
Reproduction steps
Check the difference in build size.
Screenshots
three V 0.150.0 Build
three V 0.148.0 Build
Vite config
Version
0.150.0
Device
Desktop
Browser
Chrome
OS
No response
The text was updated successfully, but these errors were encountered: