koute / cargo-web

A Cargo subcommand for the client-side Web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cargo-web tet fails, no .js file found

scifi6546 opened this issue · comments

I setup a empty repository with no tests and cargo-web complains that it can not find a .js file. I have chromium installed and I am running on ubuntu 20.04

cargo-web test --verbose
       Fresh cargo-web-test v0.1.0 (/home/nick/programming/cargo-web-test)
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
thread 'main' panicked at 'internal error: no .js file found', /home/nick/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-web-0.6.26/src/test_chromium.rs:125:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cargo-web -V    
cargo-web 0.6.26

Are you running on the nightly builds? I noticed this start to occur when the nightly build updated to a 1.44 version from 1.43.

I root caused this to the .wasm artifact that is generated now gets put under the /target/deps/ folder whereas previously it was just under /target/. This causes it to be explicitly filtered out by cargo-web as they do some modifications to the wasm as a post-process step. I'll report the details on cargo-web and see if I can put together a PR for a fix.

For reference see cargo-web - src\build.rs:

fn build_or_check( &self, config: &AggregatedConfig, target: &CargoTarget, should_build: bool ) -> Result< CargoResult, Error > {

...

build_config.build( Some( |artifacts: Vec< PathBuf >| {
                let mut out = Vec::new();
                for path in artifacts {
                    let skip =
                        is_wasm32_unknown_unknown &&
                        path.extension().map( |ext| ext == "wasm" ).unwrap_or( false ) &&
                        path.parent().and_then( |parent| parent.file_name() ).map( |dir| dir == "deps" ).unwrap_or( false );

                    if skip {
                        continue;
                    }

                    if let Some( artifact ) = wasm::process_wasm_file( config.uses_old_stdweb, self.build_args.runtime, &build_config, &prepend_js, target_dir, &path ) {
                        debug!( "Generated artifact: {:?}", artifact );
                        out.push( artifact );
                    }

                    out.push( path );
                }

                out
            }))

It looks like for emscripten you will also need this change: #244

There are several assumptions around not dealing with .wasm files under the deps folder for cdylib crates. I am not familiar enough with the code base to identify the right fix here without causing breakage to other tests.

This commit from last April is now unfortunatley not compaible with the changes made by the build tools: 0f6c482#diff-9300feef84bdf7e5ab58b05fa4eb0794

@koute is this project still alive?

We had to remove stdweb from our CI (rust-random/getrandom#154) due to this. Is there a way to work around this issue?