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

QUESTION: How does one leverage the --target experimental-nodejs-module flag? #1445

Open
NerdyDeedsLLC opened this issue Nov 6, 2024 · 0 comments

Comments

@NerdyDeedsLLC
Copy link

Hey gang:

Sorry if this is in the wrong place; I wasn't certain where/who else to ask. Contained within the deployment.md file is a section detailing:

Node.js Module

--target experemintal-nodejs-module

If you're deploying WebAssembly into Node.js as a JavaScript module,
then you'll want to pass the --target experimental-nodejs-module flag to wasm-bindgen.

Like the "node" strategy, this method of deployment does not
require any further postprocessing. The generated JS shims can be imported
just like any other Node module.

Note that this method requires a version of Node.js with WebAssembly and module support,
which is currently Node 12 and above.

Currently experimental. Target is expected to be changed before stabilization.

... that suggests passing --target experimental-nodejs-module to wasm-bindgen may allow for the generation of non-webpack-exclusive JS modules.

The only problem is, wasm-pack doesn't seem to support that flag value (although bundler, web, nodejs, deno, no-modules all seem to work fine). I'm not crystal-clear HOW to pass a flag directly to wasm-bindgen (as every example I find seems to be leveraging wasm-pack, and I cannot figure out where the reference to bindgen is occurring).

image

Any suggestions would be most welcome?

@NerdyDeedsLLC NerdyDeedsLLC changed the title QUESTION: How does one leverage the QUESTION: How does one leverage the --target experimental-nodejs-module flag Nov 6, 2024
@NerdyDeedsLLC NerdyDeedsLLC changed the title QUESTION: How does one leverage the --target experimental-nodejs-module flag QUESTION: How does one leverage the --target experimental-nodejs-module flag? Nov 6, 2024
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

No branches or pull requests

1 participant