I am in the process of writing a rather large JavaScript library using the Closure Compiler, but I made a smaller mock up to use as an example of this issue:
src/main.js:
export function main(str) {
console.log("From main: " + str);
}
Command:
google-closure-compiler --compilation_level ADVANCED_OPTIMIZATIONS --language_in ECMASCRIPT6 --language_out ECMASCRIPT6 --js_module_root src/ --module_resolution node --js src/main.js --js_output_file build/main.min.js
Expected Result (roughly):
export function main(str){console.log("From main: "+str)}
Actual Result:
'use strict';
Long story short, I've been struggling for hours, and I can't figure out how to get Closure Compiler to respect ES6 "export" statements. I've tried googling many times, but I can only get results for "goog.modules", which isn't what I want. Any help would be appreciated.
Closure Compiler does not currently support modules as output (in any format).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With