-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Provide minified version of three.module.js #15176
Comments
Actually, I think this is a fair thing to ask. We have changed all the examples to use Not everyone wants to dive in the rabbit hole of bundlers. |
Closure Compiler says that it supports ES6 as output too? |
That seems pretty nonstandard to me; better practice is for users to do minification after tree-shaking in their build. The subset of users who are going to copy/paste scripts without a build step AND use ES modules is diminishingly small, and I think we can avoid adding a new build artifact for them by recommending CDNs like JSDelivr and Unpkg instead. JSDelivr provides minification automatically:
... we could provide |
+1 for this. We'll just be adding complication to the build while directing inexperienced users to use the library in a sub-optimal way. Non-minified code works fine, it's just not production-ready. Inexperienced users will need to work out how to minify their code for production at some point, so I don't see the need for hand-holding here. |
Context from #17276:
@mrdoob replied:
I replied:
Then the discussion was moved here. My reply was intended as part of the quoted discussion, so then I copy the above discussion here too, hoping that this issue can contain a more general discussion about builds. |
I think as said above, most of us use the ES6 version uncompilled so then our three shaking could only import what we're using (it's not working at the moment, but that's not the point of this reply). What would be the use case for a three.module.min.js? It would be harder for you to debug errors if you import a minified version of a library while developing. Are you thinking of using three.module.min.js as a module in your html? or are you thinking of having a bundler like webpack, rollup, whatever, to bundle your project which uses three.js? |
Yeah, I think @mrdoob is referring to beginners how implement their code similar to the examples within a |
I think beginners who base their development efforts on copy-paste from the examples will not benefit from the examples using a minified version, since that is harder to debug, and will not necessarily benefit from the mere existence of a minified version either, when that is not enabled in examples by default. Hm. |
Some context: Using the unminified version of |
The essence of my digging into that reference, is @bhouston asking:
followed by @WestLangley agreeing and making a PR. |
I've experimented a bit with with import * as THREE from "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.min.js";
import { OrbitControls } from "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/controls/OrbitControls.js"; As you can see in this live example, the setup will import Hence, providing |
@mrdoob I would say this issue can be closed. The concept of having a minified core build is not appropriate in context of ES6 modules. Code minification/obfuscation needs to be handled on app level. |
@Mugen87 Agreed! |
Description of the problem
Three supports es6 modules, including a rollup, three.module.js. It does not provide a minified version, however.
This is a feature request to include three.module.min.js in the distribution.
The lack of three.module.min.js may be a result of the popular minifiers initially not being able to minify es6. This is no longer the case, see: butternut/squash https://github.com/Rich-Harris/butternut. Also uglify-es is a version of uglify-js that can minify es6+.
Three.js version
See the unpkg dashboard: https://unpkg.com/[email protected]/build/
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)
The text was updated successfully, but these errors were encountered: