jhugman / uniffi-bindgen-react-native

A uniffi bindings generator for calling Rust from react-native
https://jhugman.github.io/uniffi-bindgen-react-native/
Other
50 stars 5 forks source link

Document steps for how to publish a uniffi'd project on npmjs #121

Closed Johennes closed 1 month ago

Johennes commented 1 month ago

After setting up UBRN in a new project created with create-react-native-library@0.35.1, I had to add the following to .gitignore to exclude the Rust checkouts and binaries from git:

# uniffi-bindgen-react-native
rust_modules/
*.a

When packing the library for publishing, npm appears to have special logic for combining .gitignore and the files array from package.json.

For Android, *.a in .gitignore and "android" in files results in the android/src/main/jniLibs/$target/$library.a files being included in the package.

For iOS, however, in order to include build/$library.xcframework, I had to add "build" to files to undo the build/ from .gitignore.

I'm not yet sure how to best publish packages built with UBRN but decided to log this here for documentation in the meanwhile. Changes to .gitignore and or files appear to be needed regardless of whether one wants to include the binaries in the package or not.

jhugman commented 1 month ago

In truth, I haven't spent very much time writing Javascript/Typescript, or in this community.

I don't really know how people are going to want to distribute uniffied packages via npm.

I am kinda waiting for—/ hoping that— the community (including you!) will work out what to do next.

At a minimum, I can add some .gitignore instructions to the tutorial, but I'd love to see more patterns of usage and more developer input before writing either code or more comprehensive docs.

I'm going to add the label:help+wanted tag to this issue.

Johennes commented 1 month ago

I've successfully published https://www.npmjs.com/package/@unomed/react-native-matrix-sdk with the binaries for all targets except for x86 on the public npm registry yesterday. The unpacked size is ~430MB. Packed is about a third.

Annoyingly, I wasn't able to find any official reference for the maximum allowed package or file size. So I'm not sure how much head room there is.

Including the binaries in the package has the huge advantage that consumers don't need to spend an hour building matrix-rust-sdk in release mode.

jhugman commented 1 month ago

@Johennes' review for #125 had a lot of good suggestions; we should not close this yet.