Skip to content

Improve wasm support #44

Description

@maxmousse

Hi everyone,

First, thanks for maintaining this package, it makes working with rust in nx really smooth =)

I tried to use the @monodon/rust nx plugin to work with wasm in an nx repository and I found some small bugs and maybe possible enhencements:

Bugs:

Enhancements:

  • the wasm-pack executor directly runs wasm-pack, which requires to have wasm-pack installed globally. I think wasm-pack is available as an npm dependency, so it would be possible to run it with npx in the executor and avoid a global installation no ? Also, the npm dependency could be added by the wasm-pack generator.
  • Once the wasm package is generated by the executor, it is located in the dist folder and it can not be easily consumed from there by another js/ts app/lib of the repo. The easiest solution I found was to install the generated package as an npm dependencie. I don't know if it's a good practise, or if there is a more elegant solution. But if it appears to be a correct solution, maybe it could be added as an option to the wasm-pack executor ?

For now, I ended using nx-command to play arround the existing problems:

 "targets": {
    "build": {
      "outputs": ["{options.output}"],
      "executor": "nx:run-commands",
      "options": {
        "commands": [
          "npx wasm-pack build libs/wasm-package --out-dir ../../dist/wasm/wasm-package --target bundler --dev --scope ml",
          "npm i dist/wasm/wasm-package"
        ],
        "parallel": false,
        "output": "dist/wasm/wasm-package"
      }
    },

It's an easy fallback solution, but it would be awesome to have wasm-support with this plugin! I am willing to help and I can provide a pull request for the two enhencements if they're found to be relevant =)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions