My workflow for es6 uses babel and babel-plugin-transform-es2015-modules-system.js to only transform module import/export for use with system.js. I simply use a "green" browser for all es6 features except import/export of modules .. which are a whatwg standard thus not "es6".
This works with legacy (non-es6) libraries well, I can "import" all the npm packages I need. Somehow babel, with only the babel modules transform, and system.js magically work.
Except for three.js. I tried it with all three releases: three.js, three.min.js & three.modules.js. The first two fail silently, resulting in a "undefined" module. The third fails, wanting traceur .. I guess for a system.js-like transform?
So what do I need to do to use three.js in my es6 world?
I guess I could just use a <script>
tag and a global for three. Or possibly use rollup/webpack to eliminate the modules?
But I bet there's a reasonable solution. After all, three.js uses es6 modules internally.
There was a bug in the release (only one day old!). I fixed it but still had problems. I did however find that this does work:
.. but the more obvious versions,
do not appear to work.
Let me know if you grok this better than this, which is pretty random.
I just had the same problem, but realized that THREE does not export THREE but instead all the different modules. Check the section in the three.js file with the exports:
... etc
So you can import just the modules you actually need, or as said above: Import all of them via
Cheers