Skip to content
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

ESM isn't suited for importing objects containing non-JavaScript identifiers #39

Closed
ghost opened this issue Oct 10, 2020 · 3 comments
Closed

Comments

@ghost
Copy link

ghost commented Oct 10, 2020

Example:
A JavaScript module imports a Wasm module, the Wasm module is as follows:

(func (export "+") (param f64 f64) (result f64)
    local.get 0
    local.get 1
    f64.add
)

How does JavaScript import that?

Yes, ESM allows renaming imports, but it doesn' not allow surrounding them with quotes or something that would allow any name to be imported and renamed.

Currently, this would result in a syntax error:

import { "+" as add } from "./module.wasm";

How would this be handed?

@devsnek
Copy link
Member

devsnek commented Oct 10, 2020

We are adding this exact functionality to JS: tc39/ecma262#2154

@ghost
Copy link
Author

ghost commented Oct 11, 2020

We are adding this exact functionality to JS: tc39/ecma262#2154

Oh perfect, beat me to it.
It seems to have already passed the proposal stage and is already being worked on implementation?
If so, I'll close this issue as it is no longer true.

@ghost ghost closed this as completed Oct 11, 2020
@ExE-Boss
Copy link

ExE-Boss commented Oct 22, 2020

You can already do the following, which is what I’d presume transpilers might do:

import * as _module_wasm from "./module.wasm";

And then instead of add, you’d use _module_wasm["+"].

This issue was closed.
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

2 participants