Skip to content

Allow ES6 in emscripten output #11984

@sbc100

Description

@sbc100

We have a lot JavaScript code that emscripten generates and currently we limit all of it ES5 in order to maximize the portability of the output code.

However, given that non-ES5 runtime as rare (citation needed?), and that there are tools such as babel for converting ES6 to ES5 it seems like the wrong tradeoff to ask all emscripten JavaScript code to avoid modern features for this reason.

I recently ran across this in #11979 where the use of an ES6 feature would save code size and (I think) performance for the vast majority of our users.

Also see #11858

I propose that we remove this restriction and allow all ES6 features in emscripten output. The remained question is now we support user who need ES5 output. Do we:

A. Do nothing. Assume that our users who want to target older engine are well versed in running babel themselves and put the burden on them.
B. Add a compatibility option -s MIN_ES_VERSION=5? Or just -s ES5? This would most likely mean taking an internal dependency on babel and running it as part of the post-link process.

We could also do a hybrid approach where we poll our users and ask how many would want option B? Or at least we cpi;d delay the implementation of option B until we know we there a non-zero number of such users?

Please excuse me if this is a duplicate issue. I'm fairly sure I've seen similar a one but I couldn't find it in a search for ES6 or ES5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions