Skip to content

Commit bbab5a7

Browse files
committed
Fix export syntax of WebAssembly to be same as ES Module Integration Proposal
1 parent 865d3ea commit bbab5a7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The communication between React app and React Native app will be also simplified
3131
- `.css` is injected to the HTML head of WebView, like [css-loader](https://github.com/webpack-contrib/css-loader).
3232
- `.bmp`, `.gif`, `.png`, `.jpg`, `.jpeg`, `.webp` and `.svg` are loaded as base64 encoded url, like [url-loader](https://github.com/webpack-contrib/url-loader).
3333
- `.htm` and `.html` are loaded as string, which can be rendered with React's dangerouslySetInnerHTML.
34-
- `.wasm` is imported as [WebAssembly instance](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance), so you can call its methods like `foo.exports.bar();`.
34+
- `.wasm` is imported like [Node.js](https://nodejs.org/api/esm.html#esm_wasm_modules), which is compatible with [ES Module Integration Proposal for WebAssembly](https://github.com/WebAssembly/esm-integration).
3535

3636
If you have some feature requests or improvements, please create a [issue](https://github.com/inokawa/react-native-react-bridge/issues) or [PR](https://github.com/inokawa/react-native-react-bridge/pulls).
3737

src/plugin/__snapshots__/metro.spec.js.snap

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/plugin/transformer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ const injectImage = (filename, ext) => {
9393
const injectWasm = (src) => {
9494
const buf = new TextEncoder().encode(src);
9595
return `
96-
export default (function () {
96+
module.exports = (function () {
9797
const wasmModule = new WebAssembly.Module(Uint8Array.from([${buf.toString()}]));
9898
const instance = new WebAssembly.Instance(wasmModule);
99-
return instance;
99+
return instance.exports;
100100
})();
101101
`;
102102
};

0 commit comments

Comments
 (0)