Closed sdykae closed 3 years ago
Hi @sdykae, ES6 support was on our wish-list and it was recently merged into Cheerp.
An explanation of the feature is here: https://leaningtech.github.io/cheerp-meta/pages/ES6-Modules.
ES6 modules generated by Cheerp will have as default export an initializing function: example.
Basic syntax:
import instantiate from './add.js'
var module = await instantiate();
var add = module.add;
console.log(add(23, 23));
The syntax you suggest is available by composing the original module with a wrapper module: complete example on GitHub's Gist
Composed syntax:
import instantiate from './add.js'
var module = await instantiate();
var add = module.add;
export {add};
then
import {add} from "./wrap_add.js"
console.log(add(23, 19));
ES6 modules? import { add } from "./file.js"; import { add } from "./file.ts"; (with tipes :(?)