rustyscreeps / cargo-screeps

Build tool for deploying Rust WASM code to Screeps game servers
MIT License
25 stars 13 forks source link

'cargo web' generated unexpected JS suffix! #10

Closed fuchsnj closed 5 years ago

fuchsnj commented 6 years ago

I received this error

error: 'cargo web' generated unexpected JS suffix! This means it's updated without 'cargo screeps' also having updates. Please report this issue to https://github.com/daboross/screeps-in-rust-via-wasm/issues and include the last ~30 lines of /home/nathan/repos/screeps-starter-rust/target/wasm32-unknown-unknown/release/screeps-starter-rust.js

Last ~30 lines, as requested by the error

    if( __load_asynchronously ) {
        return WebAssembly.instantiate( __wasm_module, __imports )
            .then( instance => {
                __instantiate( instance );
                console.log( "Finished loading Rust wasm module 'screeps_starter_rust'" );
                return Module.exports;
            })
            .catch( error => {
                console.log( "Error loading Rust wasm module 'screeps_starter_rust':", error );
                throw error;
            });
    } else {
        const instance = new WebAssembly.Instance( __wasm_module, __imports );
        __instantiate( instance );
        return Module.exports;
    }
}

    if( typeof window === "undefined" && typeof process === "object" ) {
        const fs = require( "fs" );
        const path = require( "path" );
        const wasm_path = path.join( __dirname, "screeps-starter-rust.wasm" );
        const buffer = fs.readFileSync( wasm_path );
        const mod = new WebAssembly.Module( buffer );

        return __initialize( mod, false );
    } else {
        return fetch( "screeps-starter-rust.wasm", {credentials: "same-origin"} )
            .then( response => response.arrayBuffer() )
            .then( bytes => WebAssembly.compile( bytes ) )
            .then( mod => __initialize( mod, true ) );
    }
}));
daboross commented 6 years ago

Thanks for reporting this!

As mentioned this is due to cargo-web updating and my fragile transform not yet being updated. I'll push an update today!

daboross commented 6 years ago

Released as cargo-screeps 0.1.3.