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

Improve wasm support #44

Open
maxmousse opened this issue Feb 16, 2024 · 2 comments
Open

Improve wasm support #44

maxmousse opened this issue Feb 16, 2024 · 2 comments

Comments

@maxmousse
Copy link

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 =)

@Cammisuli
Copy link
Owner

Thanks for your input!

The whole wasm support wasnt finished, and definitely not tested properly. I want to finish support for it.

I'm holding off on finishing this until I refactor the plugin to work with project crystal in Nx. In essence, there's no executors, but we rather set up the commands behind the scenes like in the example you have with wasm-pack.

Currently I'm waiting for a new design/feature in Nx to provide multiple targets, so that projects can build with cargo, napi and wasm-pack, without having to specify it manually.

So hold off on making the PR yet, as the whole thing will change soon-ish.

I'll let you know when this is implemented with the refactor. 🙂

@na-ji
Copy link

na-ji commented Sep 17, 2024

Maybe the #22 could be merged while working for the project crystal support? This way it won't be an issue for anybody.

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

3 participants