Skip to content

Instantly share code, notes, and snippets.

@ifiokjr
Last active November 12, 2021 07:47
Show Gist options
  • Select an option

  • Save ifiokjr/c78928e36c669c72b2c533959ce3636e to your computer and use it in GitHub Desktop.

Select an option

Save ifiokjr/c78928e36c669c72b2c533959ce3636e to your computer and use it in GitHub Desktop.

Initial thoughts on napi-rs

It's quite magical and enforces a structure that makes it quite hard to use in monorepos.

I've been building monots recently to make managing library code a lot easier.

Some things I've noticed that I'm not a fan of at the moment.

  • napi places the platform specific code in a sub directory. npm/darwin-x64 for example. I like all packages to be directly under the packages/ folder. I've looked at the napi code and there's currently no way to change the destination directory.
    • I would like the files to be placed in the packages/skribble.dev__css-darwin-x64 folder. So I'll need to create my own custom scripts for it.
  • I'm not sure how the optionalDependencies work. I can see that napi prepublish adds them to the package.json file. But I need to find out if the optional dependencies are automatically installed by the package manager for the relevant platforms.
    • Okay, just had a look and it seems that optionalDependencies will attempt an install but not complain if it fails. So napi adds and os field which is probably looked at by the package manager when deciding whether to install the dependency or not.

I'm not sure whether it's possible to use esmodules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment