question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating Three.js Closure Compiler Build path to ES6 Modules.

See original GitHub issue

Hello,

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:closed
  • Created 7 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MatrixFrogcommented, Aug 16, 2016

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.

1reaction
mkeblxcommented, Aug 16, 2016

Yes… you do need to omit the file extension in index.js: import { Layers } from './Layers';

And, for warning:

/**
 * @constructor
 */
function Layers() {

    this.mask = 1;

}

And can use wildcard.

java -jar closure-compiler-v20160713.jar --warning_level=VERBOSE --language_in=ECMASCRIPT6_STRICT --js **.js --js_output_file test.js
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found