How to use wasm-pack without having to publish to npm


I am attempting to write Rust, compile to WASM, and import into a JS module. I am following the wasm-pack tutorial. I can get the wasm code to run after I build / publish to the npm registry. However, I'd like to find a way to work with a local version and ideally even hot reload (although I can live without hot relaod).

I plan on importing into a large npm project, cesium js to be exact: GitHub - CesiumGS/cesium: An open-source JavaScript library for world-class 3D globes and maps 🌎

right now in my package.json I have :

  "devDependencies": {
    "cesium-wasm": "^0.1.0",

but I'd like to be able to statically reference a file path like:

  "devDependencies": {
    "cesium-wasm": "^../../cesium-wasm/pkg",

But when I do this I get a webpack error: ERROR in ../my-lib/pkg/hello_wasm.js 100:52

Module parse failed: Unexpected token (100:52)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See
|     if (typeof input === 'undefined') {
>         input = new URL('hello_wasm_bg.wasm', import.meta.url);
|     }
|     const imports = __wbg_get_imports();
 @ ./index.js 1:0-37 3:0-5
 @ ./bootstrap.js

I can't figure out what I am doing wrong, thank you for any advice you can offer. I am also open to a different approach as long as it works with JS modules and will not require starting from scratch (It's vital that I can add it to the Cesium repo).

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.