One interesting feature of Cheerp is its cheerp-wasm
target, which compiles C++ into both a .js
file and its corresponding .wasm
file. Essentially, the .js
file acts as a loader for the WebAssembly code.
This particular loaderđź”— uses require("path")
to bring in essential filesystem functionalities needed to load the .wasm
file as a module. Unfortunately, the environment where my code operates (Screeps) does not support this "path"
module.
[8:39:54 AM][shard3]Error: Unknown module 'path'
at Object.requireFn (<runtime>:31712:23)
at fetchBuffer (main:10:5)
at main:30:1
at main:42:3
at Object.exports.evalCode (<runtime>:15584:76)
at Object.requireFn (<runtime>:31730:28)
at Object.exports.run (<runtime>:31673:60)
Given that the Cheerp loader relies on functionality that I can't access, how can I properly load my wasm code?
Although Cheerp presents various flags that can be configured, none seem relevant to my current predicament.
Is there a way to direct Cheerp to simply call
bytecode = require("mycode.wasm")
and utilize that? Could Cheerp potentially incorporate the wasm directly as bytecode within the .js itself? Or should I consider developing my own custom loader instead?