closure-compiler
closure-compiler copied to clipboard
Support es6 exports from --entry_point
Support export statements from the entry point file. This will enable many requested features such as
- import chunking (e.g., Dynamic Import Support)
- dynamic import
while giving the user precise control.
Given a file
// entry.js
import { m1, m2 } from "./mod"
...
...
export { sym1, ..., symN }
export default symDefault;
When compiled with
google-closure-compiler -O ADVANCED --js mod.js entry.js --entry_point entry.js --module_resolution NODE
should output a file containing export { sym1, ..., symN, symDefault as default}.
Currently, this behavior can be achieved by assigning each exported symbol to globalThis in a preprocessing step and then replacing each such assignment in the compiled file to an export statement in a postprocessing step.
Closure compiler is stripping off the default exports. Facing this problem with emscripten generated ES6 code. When are we getting this feature ? Or at-least a workaround ?
At KimlikDAO we have a wrapper around Google Closure Compiler called kdjs which supports
- export statements
- import statements that are to be left as is (not "linked" or packaged in)
This or something like this could help you. https://github.com/KimlikDAO/kimlikdao-js/tree/ana/kdjs
Using this you can compile a fully fledged es6 module having both import and export statements and is type checked an optimized.