closure-compiler icon indicating copy to clipboard operation
closure-compiler copied to clipboard

Support es6 exports from --entry_point

Open KimlikDAO-bot opened this issue 1 year ago • 2 comments
trafficstars

Support export statements from the entry point file. This will enable many requested features such as

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.

KimlikDAO-bot avatar May 30 '24 02:05 KimlikDAO-bot

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 ?

amitdhiman000 avatar Jul 14 '24 15:07 amitdhiman000

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.

KimlikDAO-bot avatar Aug 19 '24 20:08 KimlikDAO-bot