-
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
Support targeting Node #266
Comments
Hey @nikgraf so this is doable. However, the major blocker is |
Thanks for the clarification 👍 |
hey @nikgraf - so wasm-pack can support node by exporting CommonJS. would this work for you? we aren't currently of the impression that es6 modules on node are stable enough to support. you would need nodejs with a flag, which also still has bugs and edgecases, and we don't have a way to give reliable commonjs fallback either, which is frustrating. let me know if the CommonJS use case works for you! you can use it by running |
This isn't blocking to me. The issue is that the current ESM implementation in bundler and the future one in Nodejs, will have some differences, I wouldn't work on making ESM for bundler also compatible for Nodejs. |
@ashleygwilliams just tried it and works like a charm. I thought loading WASM won't work with CommonJS, but I does just fine. Thanks! |
Great to hear! Glad it worked for you :) |
💡 Feature description
I was trying @xtuc's wasm-node-loader, but noticed the output of wasm-pack is not compatible to Node 10.
Three things I noticed:
.js
, but node will require a.mjs
ending..wasm
. e.g.import * as wasm from './app_bg';
. With the node loader it should beimport * as wasm from './app_bg.wasm
."./app.js"
, but not sure where this was coming from.I'm not sure what's the best way forward. wasm-pack could support a commnand line flag for
wasm-pack build
to target node. On the other hand maybe it needs a different node loader.The text was updated successfully, but these errors were encountered: