-
Notifications
You must be signed in to change notification settings - Fork 409
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
Missing wasm-bindgen file in package.json #199
Comments
hi @mciantyre thanks for the very detailed bug report! the reason that the could you share the full generated thanks again for the report and sorry you are running into this! |
Of course! It looks like {
"name": "js-hello-world",
"collaborators": [
"Ashley Williams <ashley666ashley@gmail.com>"
],
"description": "an example rust->wasm crate",
"version": "0.1.0",
"license": "WTFPL",
"repository": {
"type": "git",
"url": "https://github.com/ashleygwilliams/wasm-pack"
},
"files": [
"js_hello_world_bg.wasm",
"js_hello_world.d.ts"
],
"main": "js_hello_world.js",
"types": "js_hello_world.d.ts"
} |
ah ha! so- that's the bug, if you add the the fix should just be an update to this line, https://github.com/rustwasm/wasm-pack/blob/master/src/manifest.rs#L74, i think but i haven't poked at this locally at all. i'm curious how the tests didn't catch this, so that would also be something to look at! thanks again, and let me know if you'd like to take this on and i'll assign you |
ok! so- after pulling down several of the fixes and poking at this, i realize i missed a key portion of your bug report- the |
Thanks for taking a deeper look! I'm sorry I never tested with the non-node target flag, nor considered it in some of my rework haha. Looking forward to the 0.4.1 release! |
I think this issue happens again at |
I think if it is not that easy to get right. Why can't we just get rid of this field altogether. "files" is an optional field anyway: https://docs.npmjs.com/cli/v6/configuring-npm/package-json#files. |
wasm_game_of_life_bg.js and wasm_game_of_life_bg.wasm.d.ts are now being generated by `wasm-pack build`. There is some additional information about these files in rustwasm/wasm-pack#199 and rustwasm/wasm-pack#1193 .
Hey team! I'm hitting an issue with the packing step of
wasm-pack
. I think I'm missing a file in mypackage.json
's files section. It's affecting module resolution after Inpm install
the output fromwasm-pack pack
.Consider the test fixture
js-hello-world
. Afterwasm-pack init -t nodejs
,wasm-bindgen
generates a typescript file, two javascript files, and one WASM file:$ ls -al pkg total 624 drwxr-xr-x 9 mciantyre staff 288 Jul 6 17:08 . drwxr-xr-x 9 mciantyre staff 288 Jul 6 17:33 .. -rw-r--r-- 1 mciantyre staff 51 Jul 6 17:57 README.md -rw-r--r-- 1 mciantyre staff 74708 Jul 6 17:08 js-hello-world-0.1.0.tgz -rw-r--r-- 1 mciantyre staff 65 Jul 6 17:58 js_hello_world.d.ts -rw-r--r-- 1 mciantyre staff 4294 Jul 6 17:58 js_hello_world.js -rw-r--r-- 1 mciantyre staff 423 Jul 6 17:58 js_hello_world_bg.js -rw-r--r-- 1 mciantyre staff 216481 Jul 6 17:58 js_hello_world_bg.wasm -rw-r--r-- 1 mciantyre staff 437 Jul 6 17:57 package.json
But the
package.json
is missingjs_hello_world_bg.js
:It seems that if that third file isn't provided,
wasm-pack pack
doesn't include it in the output tar. Then, after Inpm install
the tar and require the package, node throws a module resolution error.As a minimum example, from the
tests/fixtures/js-hello-world
example:If I go back to
pkg/package.json
to make it look likere-pack with
wasm-pack pack
, and re-install the tar withnpm install
, everything is good.Sorry if this is already a known issue. If it's more helpful to have another example, let me know and I can put something together.
I have what I believe to be a fix for
wasm-pack
. My patch worked on this example and my other use-case. Say the word, and I'll open a PR!Versions of all the things:
The text was updated successfully, but these errors were encountered: