Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot resolve dependency './rust_parcel_bg.js' #45

Open
denialanderror opened this issue May 12, 2020 · 6 comments
Open

Cannot resolve dependency './rust_parcel_bg.js' #45

denialanderror opened this issue May 12, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@denialanderror
Copy link

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 denialanderror added the bug Something isn't working label May 12, 2020
@Peder2911
Copy link

Same. Just installed dependencies and tried to serve.

@zoechi
Copy link

zoechi commented May 24, 2020

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 wasm-tool/parcel-plugin-wasm.rs#30

@rrbutani
Copy link

rrbutani commented May 25, 2020

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

@Peder2911
Copy link

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

@rrbutani
Copy link

rrbutani commented May 27, 2020

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

@Peder2911
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants