Javascript's ES6(ECMAScript 2015) Support

I know about Fuse’s Javascript supports ES5.1, and will support ES6 later. Uno is good alternative for Javascript, But I want to use ES6 more fast.


Yeah, we are working on getting V8 support on Android - that’s the only missing piece :slight_smile:

Awesome. If Fuse support ES6, It will be more attractive than any javascript native app development framework. :smiley:

yeah, should be awesome :smiley:

Thought here (haven’t explore the framework much yet): Is it possible (possibly) to run the JS through a transpiler, like babel, for instance?

It is very easy to create a setup using babel as a transpiler. We do it on our project.

Add a build.bat or file to the project:

It typically looks like:

call babel *.js > ./JavaScript/Generated/JavaScript.js

Then you add Generated/JavaScript.js using <JavaScript File="JavaScript/Generated/JavaScript.js" />

Then add babel to the system and set up a Sublime Text 3 build:

npm install --global babel (requires Node.js or npm installed on the system)

Then go to: Tools -> Build System -> New Build System in Sublime Text 3.

Add this on Windows:

    "cmd": "build.bat",
    "working_dir": "$project_path",
    "windows" : {
        "shell": true

And on Mac:

  "cmd": "./",
  "windows" : {
      "shell": true

Save. Then you press Command/Control-B to prebuild your JavaScript.

In addition to Cocporn’s method, you can do the npm install -g babel, and while developing, run:

babel ./source-directory --out-dir ./compiled-directory --watch

You can also add some optional transforms and things like that if the default Babel settings don’t offer the things you need. By default, Babel transpiles everything from Stage 2 and up, so if you want things like class properties, you need to enable them manually, by either adding --optional es7.classProperties, or by enabling the entire stage of proposals by adding --stage 1.

Flow type support is also built in in Babel as an optional transform; --optional flow.

In case you get a larger bunch of options that you feel like you need to pass to Babel, consider adding a .babelrc file to your project.

Awesome, we might add some of this.

I was surprised to see babel actually supports some features from ES7 also, like async/await (enabled by default).

So it’s been 8 months since the last comment, I was wondering what the progress is for es6 native support with the javascript VM with fuse?

If you are exporting to Android, you are using V8 and that will give you a lot of the ES6 syntax. If you export to iOS we have to use JavaScriptCore wich is far from done with adding ES6 features. So you need to use a transpiler like babel in that case.

Are the steps above still the suggested way to use ES6 with Fuse or will this change over time?