test icon indicating copy to clipboard operation
test copied to clipboard

Support dart2wasm in node.js tests

Open simolus3 opened this issue 1 year ago • 0 comments

Support dart2wasm as a compiler for tests running in Node.js. dart2wasm emits a .mjs file exporting definitions to load generated wasm modules, the only additional thing we have to do is wrap that in a simple entrypoint file compiling the wasm module and invoking the startup wrapper.

There's no support for stack trace maps yet. We also don't support precompiled node wasm tests yet (dart2wasm is also not currently supported by build_web_compilers, so we're blocked on that either way).

In the test runtime, I had to migrate off require as that function is not in the global context for .mjs files. It looks like we can use await import instead though. If we need to support ancient Node versions that lack import support, I can adapt that to still use require when compiled with dart2js for compatibility.

simolus3 avatar Jul 26 '24 14:07 simolus3