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

Bring back .wasm imports #5609

Closed
hayd opened this issue May 18, 2020 · 12 comments
Closed

Bring back .wasm imports #5609

hayd opened this issue May 18, 2020 · 12 comments
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted)

Comments

@hayd
Copy link
Contributor

hayd commented May 18, 2020

It was removed in #5135
Potentially this should be behind the --unstable flag?

cc @bartlomieju

@ry
Copy link
Member

ry commented Jun 13, 2020

The wasm esm integration spec is currently stage 2. Before we add this feature (which we should) the implementors should familiarize themselves with this in-progress specification:
https://github.com/WebAssembly/esm-integration/tree/master/proposals/esm-integration
and particularly the examples:
https://github.com/WebAssembly/esm-integration/blob/master/proposals/esm-integration/EXAMPLES.md

@kitsonk kitsonk mentioned this issue Jun 21, 2020
18 tasks
@ghost
Copy link

ghost commented Sep 23, 2020

Wasn't the only thing blocking the release of this support for "top-level await," which Deno seems to have already, putting it ahead of all of the major browsers? Doesn't the current support for top-level await make Deno non-web compatible?

@Soremwar
Copy link
Contributor

Soremwar commented Sep 23, 2020

@00ff0000red Top level await is implemented by V8, not Deno. And that landed in browsers just recently, so there's not even reason to argue about it

The module implementation however IS specific to the runtime, so an implementation of WASM imports that gets rushed might break the Deno phylosophy

@kitsonk
Copy link
Contributor

kitsonk commented Sep 24, 2020

Top level await is implemented by V8, not Deno.

It is in Deno and has been for a long time. 😕

There is nothing really holding this back other than the fact that getting the semantics to line up to something that seems stalled in the stands process is a challenge/risk.

@Soremwar
Copy link
Contributor

@kitsonk I ment to say that
TLA -> Engine
WASM imports -> Runtime

@bartlomieju bartlomieju mentioned this issue Oct 10, 2020
22 tasks
@Ciantic
Copy link

Ciantic commented Oct 21, 2020

Biggest problem with the non-standard feature for imports is that what if this becomes standard which is incompatible how it was implemented in Deno?

Then there is possibility it will break the code depending on the feature, and there is no good way to highlight the error lines. To mitigate that risk there could be alternate syntax, e.g.:

unstable import * as M from "./mymodule.wasm"

or even

// @deno-import
import * as M from "./mymodule.wasm"

(In example below the Deno would not allow the import at all if the @deno-import is not there)

If the wasm module imports become a standard, then it would be as simple as removing the unstable modifier (or additionally change it because it can't be known if it works with the standard that doesn't exist).

I hope I'm making sense.

@gcxfd
Copy link

gcxfd commented Feb 9, 2021

now fetch wasm need network , how to cache all wasm and compile into exe ?

I think import wasm is important , when not support , so people have to hard code fetch wasm in library development , without cache

In many country for example china , network fetch from foreign site is sometimes blocked , so network fetch wasm often failed

@ghost
Copy link

ghost commented Feb 9, 2021

@gcxfd Can you use Deno.readFile to load the Wasm in your specific situation?

@caspervonb
Copy link
Contributor

caspervonb commented Feb 9, 2021

now fetch wasm need network , how to cache all wasm and compile into exe ?

I think import wasm is important , when not support , so people have to hard code fetch wasm in library development , without cache

In many country for example china , network fetch from foreign site is sometimes blocked , so network fetch wasm often failed

You can embed the WebAssembly module as a base64 encoded string for now (this is larger and slower so not optimal but works okay enough); with import assertions for wasm we should be able to bundle it all together but that'll be a little while.

@gcxfd
Copy link

gcxfd commented Feb 10, 2021

@gcxfd Can you use Deno.readFile to load the Wasm in your specific situation?

I can use readFile with my self wasm , but when I use the Third-party libraries which has wasm , I have to modify their code , This will make maintenance very troublesome .

So I think the earlier support for import wasm will earlier enable Third-party libraries with wasm in real world development

@ghost
Copy link

ghost commented Feb 10, 2021

Does Deno support Request caching? Ex: fetch("./lib.wasm", { cache: "force-cache" });, if so it might make your job a bit easier.

But early support means that a lot of code might break, in various ways, once the proposal is complete, and Deno implements the standard.

Regarding the issue at hand, what's preventing an experimental re-implementation of the proposal?

I'd love to be able to start up my code by running deno run -A --unstable ./main.wasm; :), even if it's experimental.

@bartlomieju
Copy link
Member

Closing as duplicate of #2552

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted)
Projects
None yet
Development

No branches or pull requests

8 participants