rust-parcel-template
rust-parcel-template copied to clipboard
Cannot resolve dependency './rust_parcel_bg.js'
Describe the Bug
Running the base template with the instructions in the readme, I get the following error:
<path>/<to>/rust-parcel-test/node_modules/parcel-plugin-wasm.rs/wasm-loader.js:2:14: Cannot resolve dependency './rust_parcel_bg.js' at '<path>/<to>/rust-parcel-test/node_modules/parcel-plugin-wasm.rs/rust_parcel_bg.js'
I've tried this with both NPM and Yarn.
Steps to Reproduce
npm init rust-parcel rust-parcel-testcd rust-parcel-testnpm installnpm run start- See error
Expected Behavior
The app should run.
Actual Behavior
The error occurs in the build.
Additional Context
MacOS 10.14.6 Node 13.12.0
Same. Just installed dependencies and tried to serve.
Any suggestion how to work around?
The file exists in crate/pkg/
Looks like some paths are mixed up.
The file wasm-loader.js is created in node_modules/parcel-plugin-wasm.rs. I'm sure that's not intentional.
Looks like https://github.com/catsigma/parcel-plugin-wasm.rs/issues/30
@zoechi That actually is intentional; the plugin goes and registers what gets output to wasm-loader.js as the wasm bundle loader here.
This error happens because wasm-bindgen changed its output for --target bundler to have a second .js file (called <crate name>_bg.js) that the current version of parcel-plugin-wasm.rs doesn't know to look for.
I opened a PR with a fix here (the PR's message also has some more details about other possible solutions). It hasn't been merged yet but if you don't want to wait, changing your package.json to point to the PR's repo should (hopefully) work:
- "parcel-plugin-wasm.rs": "^1.2.15"
+ "parcel-plugin-wasm.rs": "rrbutani/parcel-plugin-wasm.rs"
Hey! Seems like there is something more going wrong. Using your fork, i get an "Error writing to cache" after updating the code two times (predictable). The error is:
Error writing to cache: Cannot read property "replace" of undefined
@Peder2911 Whoops, sorry about that!
There was an extra commit on the master branch (not stopgap which the PR is based on) that tried to register a dependency that didn't exist. It should be fixed now.
Either switching to the stopgap branch ("rrbutani/parcel-plugin-wasm.rs#stopgap", I think) or running yarn upgrade parcel-plugin-wasm.rs/npm upgrade parcel-plugin-wasm.rs should fix it.
Hmm, weird, hot-reload still doesn't work after two reloads. The page just doesn't update along with the code, even though it is refreshed. Error is gone though, thanks! P