Skip to content

Document EXPORT_ES6 #14383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RReverser opened this issue Jun 4, 2021 · 10 comments
Open

Document EXPORT_ES6 #14383

RReverser opened this issue Jun 4, 2021 · 10 comments

Comments

@RReverser
Copy link
Collaborator

I've just noticed that EXPORT_ES6 option, while very useful in modern Web development stack, is currently undocumented (not counting settings.js note) and not even mentioned anywhere on the website: https://emscripten.org/search.html?q=EXPORT_ES6&check_keywords=yes&area=default#

At the very least, it would be useful to mention it in the same places where we have MODULARIZE: https://emscripten.org/search.html?q=MODULARIZE&check_keywords=yes&area=default#

@sbc100
Copy link
Collaborator

sbc100 commented Jun 4, 2021

Would this be solved (at least partially) by exporting/exposing the existing docs that exist for all settings in settings.js on the docs site?

@RReverser
Copy link
Collaborator Author

Do you mean https://emsettings.surma.technology/#EXPORT_ES6?

If so that's what I meant by "not counting settings.js note" - I don't think that's enough. It doesn't mention .mjs automatically enabling EXPORT_ES6, the MODULARIZE note is outdated (it's auto-implied now), doesn't show usage example etc.

But yeah I guess it would be better than nothing.

@sbc100
Copy link
Collaborator

sbc100 commented Jun 4, 2021

Ah I see. In that case I agree.

Do you think updating/improving the docs in settings.js would be enough? Maybe if we also make those more visible? Or do you want to this more front and center somewhere?

@RReverser
Copy link
Collaborator Author

I think updating it in settings.js would be certainly useful either way, but I also think we should encourage new users to use EXPORT_ES6, as it provides better integration with modern tooling, better minification etc. In order to push users in that direction, we'd need to have some front & center instructions too.

In particular, I think adding a section very much like https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html?highlight=modularize#interacting-with-an-api-written-in-c-c-from-nodejs but for EXPORT_ES6 would be useful.

For now I keep running into users (e.g. on StackOverflow) who are linking back to @surma's https://developers.google.com/web/updates/2019/01/emscripten-npm as the only guide for emitting ES6 modules, and until I tried to search emscripten.org for "EXPORT_ES6" I didn't connect the dots that it's literally the only guide out there.

It's well written, but 1) it's a bit outdated by now, 2) it explains several features at once and 3) not part of the official docs, so I think a dedicated official section is still useful.

I can probably try and add this to my backlog, but wanted to open an issue for tracking and also just in case someone wants to write those docs up sooner :)

@sgbeal
Copy link

sgbeal commented Nov 3, 2022

Bump! We're trying to figure out how to create es6 module builds for the new sqlite3.org WASM builds and the only docs about it in settings.js are not nearly meaty enough to work through this. This is where google led me when i asked about es6 modules with Emscripten:

http://philiplassen.com/2021/08/11/node-es6-emscripten.html

Searching emscripten.org for EXPORT_ES6 currently returns 0 results.

@RReverser
Copy link
Collaborator Author

@sgbeal Node + ES6 is not supported today, it's a separate longstanding issue. You might want to subscribe and check out the PRs: #11792

@sgbeal
Copy link

sgbeal commented Nov 3, 2022

i don't care about node.js (quite the opposite!). We're currently only interested in browser-side builds.

@iliakan
Copy link
Contributor

iliakan commented Feb 18, 2023

Is this option working for browser builds? The changes seem to be purely cosmetic on JS side.

@dhdaines
Copy link

Is this option working for browser builds? The changes seem to be purely cosmetic on JS side.

Works For Me™: https://www.npmjs.com/package/soundswallower?activeTab=explore (built with https://github.com/ReadAlongs/SoundSwallower/blob/master/js/CMakeLists.txt)

@dhdaines
Copy link

dhdaines commented Mar 2, 2023

Hi! I'll try to put together a PR for documentation, for the moment you can also look at the packaging guide I've written. There are still some bugs in EXPORT_ES6 like #18811, perhaps I will try to make PRs for them as well...

lopopolo added a commit to artichoke/playground that referenced this issue Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants