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

Synchronously importing wasm modules in the main chunk #6615

Open
alexcrichton opened this Issue Feb 28, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@alexcrichton

alexcrichton commented Feb 28, 2018

Do you want to request a feature or report a bug?

bug

What is the current behavior?

Currently when a wasm module is imported like:

import { foo } from './foo.wasm';
// ...

then wepack will report "Sync WebAssembly compilation is not yet implemented"

If the current behavior is a bug, please provide the steps to reproduce.

$ cat foo.wat
(module
  (type (;0;) (func))
  (func (;0;) (type 0)
    nop)
  (memory (;0;) 17)
  (export "memory" (memory 0))
  (export "foo" (func 0)))
$ wat2wasm foo.wat -o foo.wasm
$ cat index.js
import { foo } from './foo.wasm';
$ yarn run webpack index.js
yarn run v1.3.2
warning package.json: No license field
$ /home/alex/code/wasm-bindgen/js-hello-world/node_modules/.bin/webpack index.js
Hash: 64205dfbff78f2176ada
Version: webpack 4.0.1
Time: 64ms
Built at: 2018-2-27 19:15:17
Entrypoint main =
   [0] ./foo.wasm 17.5 KiB {0} [built]
   [1] ./index.js 34 bytes {0} [built]

WARNING in configuration
The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment. 

ERROR in chunk main [entry]
[name].js
Sync WebAssembly compilation is not yet implemented
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What is the expected behavior?

Both import('./foo.wasm') and import { foo } from './foo.wasm'; to work. It looks like this is intentionally unimplemented though, so I was wondering if it'd be good to have a tracking issue for this feature? Or maybe such an issue already exists!

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.

@sendilkumarn

This comment has been minimized.

Contributor

sendilkumarn commented Feb 28, 2018

Yes, it is not implemented currently. But it is very much in the cards IIUC

@alexcrichton alexcrichton changed the title from Synchronously importing wasm modules to Synchronously importing wasm modules in the main chunk Mar 3, 2018

@alexcrichton

This comment has been minimized.

alexcrichton commented Mar 3, 2018

I've updated the issue title to specifically refer to the main check as @sendilkumarn points out that synchronous imports are supported in non-main chunks!

@camerondavison

This comment has been minimized.

camerondavison commented May 19, 2018

is this fixed, i was able to build a dist/main.js following these steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment