-
-
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
Examples: add three/addons/*
alias
#23406
Conversation
Please update the manual, too 😇 . |
@Mugen87 done! |
"addons" term makes so much more sense... I'm quite new Three.js and really didn't understood why everything like +1 for |
I think I would like to explore ways of publishing both I've also noticed that Edit: |
😆😆😆
@mrdoob Sure thing! Let's compare with the separate package solution, you decide which route is worth going forward (you're the one who is gonna publish 😬). (I assume we want to keep all the code under this same repo still) To publish multiple packages we would need to:
After this setup, when you need to publish a new version, you will need to publish each package. You can do this either:
Let me know what do you think. |
If using Lerna to publish multiple packages, a nice pattern (used by Lerna itself) could be to create a
|
Not worth it imo, and it makes it too easy for consumers to mess up. E.g. you'd need to make sure |
hey @mrdoob, congrats on the release 🎉 Maybe we can get the three addons alias in this next cycle. You just have to tell me which option do you prefer:
|
Silly question, but isn't this already possible with the existing <script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.138.0/build/three.module.js",
"three/examples/jsm/": "https://unpkg.com/three@0.138.0/examples/jsm/"
}
}
</script> Same imports with ESM: https://jsfiddle.net/mattrossman/zrLu2v6x/2/ |
Yeah, although I think import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
// vs
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js' |
Why restructuring? Just one |
Is this PR blocked only on the question should-we-and-if-should-then-how publish addons as a separate package? I also think that in future when we remove |
I tend to think that we shouldn't do that. Or at least first merge this PR and then think about that... |
We really need to avoid |
Please also note #24413 (comment). |
@LeviPesin will do the |
Thanks! |
Hm, maybe we also should add such aliases for the libs? Like |
I've been thinking of these aliases as shorthands to make our recommended workflows (namely, using ES Modules) more convenient for external users. But I consider |
What if user just uses only files they needed, e.g. three.module.js, some loader using fflate, and fflate, and puts them in one folder (and does not use npm)? The user can change |
That is a workflow I'd prefer to discourage. By paving a path toward what is ultimately a fragile configuration, I think we are doing new users a disservice. three.js should offer one or two golden paths, supporting and documenting those well, and making it obvious when you're leaving that path — even if we don't ultimately require using npm. As it is, our Installation page already gives more mixed messages about how to get started than I would like. |
* Examples: use three/addons/* alias * Npm: add three/addons/* alias * Examples: remove unnecessary package.json * Fix: remove build folder from PR * Docs: use three/addons/ alias * Editor: use three/addons/ alias * Manual: use three/addons/ alias * Manual: use three/addons/ alias in examples * Add alias to new examples * Add alias to new manual entries
* Examples: use three/addons/* alias * Npm: add three/addons/* alias * Examples: remove unnecessary package.json * Fix: remove build folder from PR * Docs: use three/addons/ alias * Editor: use three/addons/ alias * Manual: use three/addons/ alias * Manual: use three/addons/ alias in examples * Add alias to new examples * Add alias to new manual entries
* Editor: use `three/addons/*` alias Follow #23406, use more alias in editor * fix: fix failed imports in last commit
Related issue: #23368 (comment)
Description
This allows us to import from examples like this:
The advantage of this aliasing is that the imports of the examples are now the same both in node and the browser.
You can test this alias here https://raw.githack.com/marcofugaro/three.js/three/addons/examples/
Note: I used
three/addons
instead ofthree-addons
as proposed here because in node,import { ... } from 'three-addons/...'
would import from thethree-addons
package instead of thethree
one.