-
Notifications
You must be signed in to change notification settings - Fork 695
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
How does the js polyfill work with ES6 modules? #252
Comments
Performance/flexibility considerations aside, the simplest approach would be for the polyfill to just generate ES5 with wide compatibility in mind. You could go further and make it do feature detection to figure out whether to generate JS that uses ES6/ES7 features like modules or int64 as appropriate instead of just emulating them, but that's more of an improvement than a feature. As far as I'm concerned modules aren't of much use to the polyfill, but you want it to interact well with consumers who want to import a WebAssembly module from ES6. That's a bit easier to tackle. |
Agreed with @kg that, when the containing app isn't explicitly using ES6 modules, the polyfill should just generate ES5 code for maximum portability, even if ES6 modules are natively supported. An interesting question is what happens when the containing app is using ES6 modules and importing wasm modules. The challenge is to translate the fetch triggered by |
For the time being at least, we will not use es6 modules at all. |
I think we can agree that one of the big motivators for the polyfill is that it will work in existing browsers. And existing browsers don't have modules. It feels like a bit of chicken/egg problem to me. I can imagine some dynamic js code generation will be necessary on client side which decides whether to use ES6 module syntax or transpile to ES5, but I don't know how feasible this is. Anyway, I don't really have an architecture in mind, so I'm wondering what are you guys thinking?
The text was updated successfully, but these errors were encountered: