OfficeDev / generator-office

Yeoman generator for building Microsoft Office related projects.
https://www.npmjs.com/package/generator-office
MIT License
837 stars 208 forks source link

WASM function gives "unable to get property ..." #632

Closed Iso5786 closed 3 years ago

Iso5786 commented 3 years ago

Expected behavior

I followed the hello world guide from https://rustwasm.github.io/docs/book/game-of-life/hello-world.html to try to load a WASM module into an Outlook addin. I expected that after I added the code to my addin's JS file to raise an alert.

Current behavior

After importing the WASM module via import * as wasm from "irmaseal-wasm-bindings" (that's how I called the module) and invoking wasm.greet() I get an error in the console: Unable to get property 'greet' of undefined or null reference (from index_bg.js)

The office version I use is 2019.

I figured that the Outlook addin runs under Edge version 18 as "Edge 18" is what I get as output when following https://stackoverflow.com/questions/5916900/how-can-you-detect-the-version-of-a-browser

And Edge 18 supports web assembly according to: https://developer.mozilla.org/en-US/docs/WebAssembly#browser_compatibility

So I am wondering if I still need to enable WASM support in the addin somehow, add a certain content security policy, etc. Or is WASM just not supported (yet) for Outlook addins even though (it looks like) Edge 18 runs under the hood?

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

Console:

Screenshot from 2021-04-30 17-31-09

Index_bg.js:

Screenshot from 2021-04-30 17-46-27

Iso5786 commented 3 years ago

A colleague showed me that with webpack one should load modules dynamically at runtime (see https://rustwasm.github.io/wasm-pack/book/tutorials/hybrid-applications-with-webpack/using-your-library.html).

I also installed Edge Webview 2 (https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section); consequently the addin runs under the Chrome engine, version 90.

Now I am getting the error: Screenshot from 2021-05-04 09-57-47

I also checked the following stackoverflow: https://stackoverflow.com/questions/63494610/can-not-use-web-assembly-rust-impl-because-of-cannot-access-wbindgen-throw

However, I am already using the experiments option syncWebassembly: true , and it doe not solve the issue.

Iso5786 commented 3 years ago

In the meantime I got it working by stumbling on this issue and related comment: https://github.com/babel/babel-loader/issues/560#issuecomment-428544754