Skip to content

Commit

Permalink
Expand publishing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Johennes committed Oct 16, 2024
1 parent d25da35 commit 27b4f87
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions docs/src/guides/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@ I would love some [help with this document](../contributing/documentation.md).

## Binary builds

In order to distribute pre-built packages you will need to add to `.gitignore` the built `.a`:
You likely don't want to track pre-built binaries in your git repository but you may want to include them in published packages. If so, you will have to work around `npm`'s behaviour of factoring in `.gitignore` when picking files to include in packages.

One way to do this is by using the `files` array in `package.json`. The steps to achieve this will depend on the particular contents of your repository. For illustration purposes, let's assume you're ignoring binaries in `.gitignore` with

```
build/
*.a
```

To include the libraries in `/build/$library.xcframework` and `/android/src/main/jniLibs/$target/$library.a` in your npm package, you can add the following to `package.json`:

```diff
# From uniffi-bindgen-react-native
rust_modules/
+*.a
"files": [
+ "android",
+ "build",
```

but add them back in to the `files` section of `package.json`[^issue121].
Another option is to create an `.npmignore` file. This will require you to duplicate most of the contents of `.gitignore` though and might create issues if you forget duplicating entries as you add them later.

[^issue121]: [This advice](https://github.com/jhugman/uniffi-bindgen-react-native/issues/121) is from @Johennes
In either case, it's good practice to run `npm pack --dry-run` and verify the package contents before publishing.

## Source packages

Expand All @@ -35,6 +44,8 @@ scripts: {
+ "postinstall": "yarn ubrn:checkout && yarn ubrn:android && yarn ubrn:ios",
```

Make sure to enable release mode in `ubrn.config` before distributing your package as the impact on size and performance can be dramatic.

## Add `uniffi-bindgen-react-native` to your README.md

If you publish your source code anywhere, it would be lovely if you could add something to your README.md. For example:
Expand Down

0 comments on commit 27b4f87

Please sign in to comment.