Emscripten: [Feature request] Option to make the glue code a ES6 Module

Created on 3 Jan 2019  Â·  4Comments  Â·  Source: emscripten-core/emscripten

In the world of bundlers, it is much easier to bundle a file that is a proper ES6 module than a JavaScript file that “clutters” the global scope.

It’d be amazing if I could opt-in into making Emscripten emit an ES6 module.

Currently, I am emulating that behavior in my projects by appending

export default Module;

or in the case of -s MODULARIZE=1 -s 'EXPORT_NAME="mymodule"'

export default mymodule;

to my glue code files.

Most helpful comment

FWIW I am writing on a getting started guide for web developers, where these kind of “good to know” things are gonna be mentioned. I’ll loop you in when I got a draft and we can decide if and where to put it.

All 4 comments

There is -s EXPORT_ES6=1 which together with MODULARIZE=1 should do this, I think? (Anywhere we should add docs about it?)

Hm yes, that’s exactly the flag I needed. Apologies for not finding it myself. I wonder if it makes sense to mention this flag here.

Hmm, I'm not sure - that's about the Module object, but not about modular output. MODULARIZE isn't mentioned there, for example. I think we mention it in passing in other places. Probably we should have a new page dedicated to modular output.

FWIW I am writing on a getting started guide for web developers, where these kind of “good to know” things are gonna be mentioned. I’ll loop you in when I got a draft and we can decide if and where to put it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hcomere picture hcomere  Â·  3Comments

id01 picture id01  Â·  3Comments

rpellerin picture rpellerin  Â·  3Comments

yahsaves picture yahsaves  Â·  4Comments

lokpoi888 picture lokpoi888  Â·  4Comments