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

URL constructor: rustpad_wasm_bg.wasm is not a valid URL. #72

Closed
jvasile opened this issue Mar 26, 2024 · 4 comments · Fixed by #74
Closed

URL constructor: rustpad_wasm_bg.wasm is not a valid URL. #72

jvasile opened this issue Mar 26, 2024 · 4 comments · Fixed by #74

Comments

@jvasile
Copy link

jvasile commented Mar 26, 2024

Did a fresh clone, then:

wasm-pack build --target web rustpad-wasm
npm install
cargo run
npm run dev

At localhost:3000, I see the following error on the web console:

Uncaught (in promise) TypeError: URL constructor: rustpad_wasm_bg.wasm is not a valid URL.
    init rustpad_wasm.js:406
    <anonymous> index.tsx:9
[rustpad_wasm.js:406:16](http://localhost:3000/node_modules/rustpad-wasm/rustpad_wasm.js)

Nothing is displayed in the browser tab.

@ntninja
Copy link
Contributor

ntninja commented Jul 18, 2024

This is most likely vitejs/vite#8427

Updating to Vite 3 or 4 partially fixes the issue, but you need to manually run the following whenever it breaks in dev mode:

cp rustpad-wasm/pkg/rustpad_wasm_bg.wasm  node_modules/.vite/deps/

Release builds (npm run build) work with Vite 3 and 4 at least.

To switch to Vite 4 after checkout run:

npm add --save-dev "vite@4"
npm install

@ekzhang
Copy link
Owner

ekzhang commented Jul 18, 2024

Thanks for figuring out this issue! I'll update the repository.

@ntninja
Copy link
Contributor

ntninja commented Jul 18, 2024

Don’t worry, I have some more fixes. I’ll make a PR then.

@ekzhang
Copy link
Owner

ekzhang commented Jul 18, 2024

Thanks. I think I got it working, by just updating sqlx and vite and running cargo update on remaining packages.

I also added "type": "module" and changed the target of the vite dev server proxy from localhost:3030 to 127.0.0.1:3030.

Feel free to make any other fixes in a PR though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants