WebAssembly Setup Issue



  • I wanted to test out the new WebAssembly support so I started up a simulation and added the WebAssembly example from the screeps documentation to my main.js file and the accompanying addTwo.wasm binary to my branch:

    
    // This will return an ArrayBuffer with `addTwo.wasm` binary contents
    
    const bytecode = require('addTwo');
    
    const wasmModule = new WebAssembly.Module(bytecode);
    
    const imports = {};
    
    // Some predefined environment for Emscripten. See here:
    
    // https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md
    
    imports.env = {
    
        memoryBase: 0,
    
        tableBase: 0,
    
        memory: new WebAssembly.Memory({ initial: 256 }),
    
        table: new WebAssembly.Table({ initial: 0, element: 'anyfunc' })    
    
    };
    
    const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
    
    console.log(wasmInstance.exports._addTwo(2,3));
    

    The issue I ran into however was that the initial line for requiring the addTwo.wasm file would produce the following debug error:

    TypeError: i.bufferFromBase64 is not a function

    Now I booted up a few other WebAssembly examples (cppreeps and a custom WebAssembly file of my own that jsut included a dumby function). Every time I would use require() to bring in the .wasm file I would receive a bufferFromBase64 is not a function TypeError.

    Has anyone else either ran into a similar issue when trying to setup WebAssembly? Thanks.


  • Dev Team

    Thanks for reporting, this issue is fixed now.