Webpack support
All the files in the v86 npm package seem to want to import fs when run in node. This means that my webpack build fails if I include V86.
Is there a way to import the browser libv86.js in node without manually managing the files?
I'd be surprised if Webpack didn't have a way to support this scenario.
We could move the code into a separate file and conditionally include it in the build process. I'm not enthusiastic, but I'd probably accept a PR. Any other suggestions?
I ran into a similar issue with a different build tool. This may seem a bit hacky, but I was able to get it working by re-compiling libv86.js with SWC.
npx \
--package=@swc/cli \
--package=@swc/core \
-- swc \
-C jsc.target=es2020 \
-C jsc.transform.optimizer.globals.typeofs.window=object \
-C jsc.transform.optimizer.globals.typeofs.require=undefined \
-C jsc.transform.optimizer.globals.typeofs.XMLHttpRequest=function \
-C jsc.transform.optimizer.globals.typeofs.process=undefined \
--out-file=libv86-web.js \
libv86.js
It might be better to do this with Closure Compiler (if it has a similar feature) since that's what is being used to build libv86.js.