Updating Three.js Closure Compiler Build path to ES6 Modules.
See original GitHub issueHello,
This month we’ve moved three.js
code base to ES6 Modules (https://github.com/mrdoob/three.js/pull/9310) and I’ve been trying to port the current Closure Compiler-based build path.
I’m having a really hard time finding command line examples of how to handle ES6 Modules.
As a simple reduced test case I’m doing this:
I have these two files: https://gist.github.com/mrdoob/7d75270a22b9d62da2e1e991ef846188
I run this:
java -jar closure-compiler-v20160713.jar --warning_level=VERBOSE --language_in=ECMASCRIPT6_STRICT --js index.js --js_output_file test.js
And I get this:
WARNING - Failed to load module "./Layers.js"
index.js:1: ERROR - required "module$Layers_js" namespace never provided
import { Layers } from './Layers.js';
^
This code compiles just fine in http://rollupjs.org/. Any ideas…?
Thanks in advance!
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
How could I effectively convert google-closure javascript to ...
1 Answer 1 ... Some highlights from each: ES6 modules can use goog.require like goog.modules to reference Closure files: const math = goog.require ......
Read more >Importing Three.js as Module - Medium
Importing Three.js as Module. I am going to show you the simplest way to use the Three.js ES6 modules in your Three.js projects....
Read more >Compiler Options - ClojureScript
:modules. A new option for emitting Google Closure Modules. Closure Modules supports splitting up an optimized build into N different modules. If :modules...
Read more >Getting Started with the Closure Library - Google Developers
Step 1: Download and Setup the Closure Library · Step 2: Create a JavaScript file that uses the Closure Library · Step 3:...
Read more >goog.require an ES6 module - Google Groups
Essentially I have a set of existing ES6 modules with imports/exports, and I want to use goog.require to pull ... to Martin Probst,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The way we translate ES6 modules, was designed with advanced compilation in mind. If you can switch to advanced mode that would be ideal. See https://developers.google.com/closure/compiler/docs/api-tutorial3
If not, there was some discussion recently about making ES6 modules work better with simple mode but I don’t know that it will happen particularly soon.
Yes… you do need to omit the file extension in index.js:
import { Layers } from './Layers';
And, for warning:
And can use wildcard.