rust-parcel-template icon indicating copy to clipboard operation
rust-parcel-template copied to clipboard

Cannot resolve dependency './rust_parcel_bg.js'

Open denialanderror opened this issue 5 years ago • 6 comments

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

  1. npm init rust-parcel rust-parcel-test
  2. cd rust-parcel-test
  3. npm install
  4. npm run start
  5. 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

denialanderror avatar May 12 '20 21:05 denialanderror

Same. Just installed dependencies and tried to serve.

Peder2911 avatar May 23 '20 12:05 Peder2911

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 avatar May 24 '20 13:05 zoechi

@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"

rrbutani avatar May 25 '20 08:05 rrbutani

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 avatar May 27 '20 18:05 Peder2911

@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.

rrbutani avatar May 27 '20 21:05 rrbutani

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

Peder2911 avatar May 28 '20 07:05 Peder2911