-
-
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
Docs: Add 'import' section. #18778
Docs: Add 'import' section. #18778
Conversation
^This needs a little cleanup on mobile. |
Interesting switch and converter. Also you hide |
Just for my understanding: Can you please explain why a separate script is necessary? Can't we just embedded a URL which links directly to https://unpkg.com/? |
@Mugen87 suppose We could do this without rehosting anything: download the ES module in I'm definitely fine with changing this, putting the download link somewhere less prominent than every single example page, or whatever. |
Thanks for the clarification! I've just misunderstood what |
There is one that does un-modularize: https://bundle.run/. But it runs Rollup and bundles dependencies (i.e. all of threejs) into the file, so doesn't really help us here. :/ |
Looking good! |
Sure – do you want the docs change to include the link to the downloadable file, or leave that to consider with a future unmodularize PR? Could also include a CDN like unpkg as an option I guess. |
Oh, I think I got confused. I thought the unmodularize script was to replace the modularize script so we could switch to update |
It is, sort of — it generates files like those have in |
f8c479f
to
922cfc3
Compare
Alright, this PR is just the docs portion now. It links to the unpkg CDN when the user clicks "Download", so for the moment there's no dependency on the unmodularize script. @mrdoob Is it correct that we want to delete |
922cfc3
to
2b725f5
Compare
Checking in on this PR again, given #18749 — if we want this import section in the docs, should the section just describe ES module import? Or should it also provide a download of the old 'global' script generated on the fly (without keeping that global script in the GitHub repository and npm package)? |
I would prefer just to describe ES6 modules and not further promote the "old" way. |
Related: #19622 |
I've reverted this to a draft for now — let me update the PR to match up with #19622 better. |
72ad18c
to
29be189
Compare
Any chances to rebase this regarding #25437? 😇 The PR could also be simplified, see #25437 (comment). |
@Mugen87 would you suggest we skip the dropdown, and just display something like this? Or keep the CDN option? import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'; |
Yes, I would skip the dropdown and displays paths like used in the Installation guide and examples so with the |
Hi guys, want me to get this done ? What order do you want these ? Under the "Examples" heading or under the "Class/Component" main heading ? |
29be189
to
1b145ec
Compare
@Mugen87 I'd never intended to give advice about using Node.js, do you mean NPM? In any case, using the @epreston let's wait until this PR is approved and merged, but once the format and wording is OK I'd be glad to have help with updating the remaining pages, thanks! I think the Import section should come after the summary paragraphs, but above any other headings, including Examples. |
So green light to bang these out ? Quick question, is there a section in the documentation that describes mapping examples/jsm to the alias I found that confusing when I first started. The distribution only contains an examples folder and like many, I spent an hour looking for the NPM package of Is this an example of what is to be inserted with the correct value to be supplied or am I missing something ? It is very rare for people to remap using the client |
The issue im describing is, copying the values from places like the install instructions or this PR does not work: import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'; This is the value that will work if you copy and paste: import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; To get the first one to work you need some trickery. |
I see: you are describing it under the context of the HTML Inline It is really handy when you want to fit everything under one page, but theres a structure that is common between 'importmap', 'browser imports', and 'bundler imports'. It requires a small change but then code will work no matter where you copy and past it. Update the 'importmap' to be: (I might need to tune this slightly) "three/examples/jsm/": "https://unpkg.com/three@<version>/examples/jsm/" This way if you create a separate 'main.js', use a bundler, or this inline |
The Both |
You're right. Because of the structure of this library, you need an 'importmap'. To get the pretty looking name The This line does nothing for vscode or build tools.
|
I may be doing a terrible job of describing it but it is a real issue. |
You know what, I'm wrong. Please ignore. This works just fine in NPM. I keep leaving the JSM in the path creating the issue.
|
Shall I get started on the docs ? Don't want to step on toes, just help out if there's bits to be done. |
There are some build tools that don't support If you're willing to help copy these snippets into more pages that would be super, thank you! 🙏 |
It's on the way. Pity we can't fix this up and drop |
There are two types of web developers, the developers that use build tools (vite, webpack, etc) and the developers that don't (import maps). The goal is to continue supporting both approaches. |
Absolutely, just wish it was in a way that was less "unique" for the people consuming the library without a build tool. I get the impression that there's a logical structure that accommodates all needs. Something that follows the same mental model as most packages. You've got to see this as well. I mean, people raise issues about this. I don't remember seeing any dependencies of this project requiring import maps to get use of them. Once you get to the point of using a shim to support the structure it may point to using a different structure. Maybe this is the best structure to accomodate developers using the library, people working on the library, tools manipulating the library, documentation running off the library. I haven't done the work to know differently. If I do find something, I'll put in a PR. |
An idea to make the
examples/js
deprecation a bit easier. This would add a snippet to each example's page in the docs, showing how to import it from npm(default) or from a CDN.Outdated screenshots
npm
cdn
Demo: https://raw.githack.com/donmccurdy/three.js/feat-unmodularize/docs/index.html#examples/en/loaders/GLTFLoader