bytecodealliance / javy

JS to WebAssembly toolchain
Apache License 2.0
2.16k stars 103 forks source link

Substitute fetch() for XMLHttpRequest() or compile Emscripten output to WASM #704

Closed guest271314 closed 1 month ago

guest271314 commented 1 month ago

What is your question?

I've been working on a fork of https://github.com/diffusion-studio/vits-web for a few days now.

I think one of the goals of the owner of the repository is to run the code in Node.js.

Anytime somebody says they want to run the code in Node.js, from my perspective that means run the code with node, deno, bun, and at least tjs (txiki.js), if not qjs (QuickJS). That's my standard practice and policy with regard to how I approach testing and experimenting with JavaScript engines and runtimes in an agnostic process. If I run code in node, that same code should at least be capable of being run in deno, and vice versa.

That ain't happening with XMLHttpRequest() references in src/piper.js. Here's the code https://gist.github.com/guest271314/3ba6e158d06a92ea62b7957e46c118f8 bundled with

deno bundle https://raw.githubusercontent.com/guest271314/vits-web/main/src/piper.js deno-piper-bundle.js

There's only 9 occurrences of XMLHttpRequest(). I can rewrite to code by hand to use fetch(). In fact I already started doing so.

I'm just curious with all the automated tools in the JavaScript/WebAssembly tooling domain is there a library or tool that replaces occurrences of XMLHttpRequest() with occurrences of fetch(), in particular JavaScript code that was output by Emscripten?