wasm-pack build --target bundler not including *_bg.js file in package.json

Created on 1 May 2020  路  7Comments  路  Source: rustwasm/wasm-pack

馃悰 Bug description

When running wasm-pack build --target bundler --scope scopename modulename, there is are both *.js and *_bg.js files generated. the package.json file looks like this
{ "name": "@scopename/modulename", "collaborators": [ "arlo <[email protected]>" ], "version": "0.4.3", "files": [ "modulename_bg.wasm", "modulename.js", "modulename.d.ts" ], "module": "modulename.js", "types": "modulename.d.ts", "sideEffects": false }

馃 Expected Behavior

I think the modulename.js line in files should be modulename_bg.js, since modulename.js file will be included anyway because of the "module": "modulename.js" line. I'm not sure about that detail, but when i do wasm-pack pack, the generated tar ball is missing the modulename_bg.js file, so my module doesn't work

馃憻 Steps to reproduce

wasm-pack build --target bundler --scope scopename modulename

馃實 Your environment

Include the relevant details of your environment.
wasm-pack version: 0.9.1
rustc version: rustc 1.43.0 (4fb7144ed 2020-04-20)

Most helpful comment

Another option:

Use cargo install --git https://github.com/rustwasm/wasm-pack.git instead

All 7 comments

After testing this out locally, it looks like both modulename.js and modulename_bg.js should be in the files list

I've just hit this, and it makes it really easy to publish packages to NPM that don't work (I've had to re-publish packages twice already because of this, meaning version bumps). The fix is apparently already merged, any chance that this can be released soon?

@Alxandr I'm just waiting for @ashleygwilliams to add me as an owner on wasm-pack so I can do the publish.

Hit this as well, already created 2 broken releases on npm :confused:

I hate to ping people, but since it's been over a month since the fix already: It would be awesome if this could be released on crates.io, @ashleygwilliams :slightly_smiling_face:

For anyone coming here from google who wants a temporary solution, my current workaround is something like

$ git clone [email protected]:rustwasm/wasm-pack.git
$ cd wasm-pack
$ cargo run -- build --target bundler ../my_wasm_project

Seems to work, but I wouldn't recommend relying on it

I think @ashleygwilliams is catching up and we'll probably have a new release not far away.

Meanwhile, to fix a broken package, I just had to:

  • edit pkg/package.json to include the *_bg.js file
  • increase the version number
  • do a wasm-pack publish after it.

Another option:

Use cargo install --git https://github.com/rustwasm/wasm-pack.git instead

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tbillington picture tbillington  路  3Comments

mikedilger picture mikedilger  路  3Comments

rbtcollins picture rbtcollins  路  3Comments

Bernd-L picture Bernd-L  路  3Comments

gliheng picture gliheng  路  3Comments