WASM imports in ava environment #2700
-
I'd like to do something like this: import test from 'ava'
test('add', async (t) => {
const wasm = await import('./dist/optimized') // <--- .wasm file
const val = wasm.add(1, 2)
t.is(val, 3)
}) Because in my application I can do this: const AsmComponent = dynamic({
loader: async () => {
const wasmModule = await import('../../../asm/dist/optimized') // <--- the same exact .wasm file
return (props) => <>{wasmModule.add(1, 2)}</>
},
ssr: false,
}) And I can use it with React like so: <p>Execute function from wasm module:</p>
<p>
1 + 2 = <AsmComponent />
</p> And it works: But in ava I get an error:
I'm not sure if it's a bug, or a feature that I lack, so I started a discussion instead of an issue. But I'd like to be able to import |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
This error is coming from Node.js, not AVA. Any chance you're compiling your application code with Babel or TypeScript? It might be modifying the exact import statement used. You might need to import |
Beta Was this translation helpful? Give feedback.
This error is coming from Node.js, not AVA.
Any chance you're compiling your application code with Babel or TypeScript? It might be modifying the exact import statement used. You might need to import
optimized.wasm
, with the extension.