-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
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
[WIP] Examples: Use ES6, build UMD examples. #13544
Conversation
I'm trying to test this, but getting an error: >> node .\examples\js\build.js
rollup:
events.js:193
throw er; // Unhandled 'error' event
^
Error: spawn rollup ENOENT
... It seems like
and it seems to be working. |
Hm I just looked through nodejs/node-v0.x-archive#2318. 😐 Using In any case I suppose the first question would be where (or if) we'd use a script like this. Ideas:
We use a bot to maintain A-Frame's |
What do you think about this approach? |
Are you thinking of generating a single import { NodeMaterial, RawNode, ... } from 'three/build/three.extras.module.js'; As one depends on the other using global I think these issues are easier to solve if the maintained copies of files are themselves ES6 modules, and we generate the UMD versions. I assume the problem there is that the live examples on the site will no longer work with normal |
This is exactly the approach that we should be taking. There exists extensive 3rd party tooling for this process in the form of Babel, Bublé etc.
This is a bit of a sticking point - the examples are the main testing ground for development, and they do need to stay in sync with any work done on the dev branch so that we can catch errors quickly. However, if we have a build script that converts the examples ES6 -> UMD, we could just use these generated files in the examples. Then we can create a script to watch the |
As I explained here we could use ES2015+ module syntax polyfill for old browser. I made a POC here, using ES2015+ module syntax: Live: https://rawgit.com/moroine/three.js/poc-example-es6/examples/misc_controls_orbit.html I have tested on IE11 and it works. It requires some time to load because of babel transpilation but IMO that's ok considering the support of the module import in browser: https://caniuse.com/#feat=es6-module |
Closing to focus on #14803. :) |
For #9562. I'm guessing this is more build process than we want, and no worries if that's the case, but I wanted to suggest this as an alternative to the other way around (write UMD, build ES6) because it has some interesting pros/cons.
I manually changed a couple examples to ES6 modules, then wrote a script to compile them to UMD modules. The UMD modules work in script tags or CommonJS. Build created as follows:
Pros:
Cons:
threejs.org/examples/*.html
must point atbuild/examples/js/*.js
, and won't "just work" for testing PRs with RawGit.