From 4180f85a6e5aeb4ef4ad98077f75dcd34e4a7e72 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Wed, 16 Oct 2024 15:07:04 +0200 Subject: [PATCH 1/3] Expand publishing docs Fixes: #121 --- docs/src/guides/publishing.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/src/guides/publishing.md b/docs/src/guides/publishing.md index 52a5de74..9107d77c 100644 --- a/docs/src/guides/publishing.md +++ b/docs/src/guides/publishing.md @@ -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 to duplicate 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 @@ -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: From e4ba61c5966c8d82b65caae329e53521063dec95 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Wed, 16 Oct 2024 16:03:09 +0200 Subject: [PATCH 2/3] Update docs/src/guides/publishing.md Co-authored-by: jhugman --- docs/src/guides/publishing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/guides/publishing.md b/docs/src/guides/publishing.md index 9107d77c..2909741c 100644 --- a/docs/src/guides/publishing.md +++ b/docs/src/guides/publishing.md @@ -41,7 +41,7 @@ scripts: { "ubrn:ios": "ubrn build ios --config ubrn.config.yaml --and-generate && (cd example/ios && pod install)", "ubrn:android": "ubrn build android --config ubrn.config.yaml --and-generate", "ubrn:checkout": "ubrn checkout --config ubrn.config.yaml", -+ "postinstall": "yarn ubrn:checkout && yarn ubrn:android && yarn ubrn:ios", ++ "postinstall": "yarn ubrn:checkout && yarn ubrn:android --release && yarn ubrn:ios --release", ``` Make sure to enable release mode in `ubrn.config` before distributing your package as the impact on size and performance can be dramatic. From 4bb1e67b46f560048ac09eebd38574862e180b7b Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Wed, 16 Oct 2024 16:03:46 +0200 Subject: [PATCH 3/3] Update docs/src/guides/publishing.md --- docs/src/guides/publishing.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/src/guides/publishing.md b/docs/src/guides/publishing.md index 2909741c..1ff5a42e 100644 --- a/docs/src/guides/publishing.md +++ b/docs/src/guides/publishing.md @@ -44,8 +44,6 @@ scripts: { + "postinstall": "yarn ubrn:checkout && yarn ubrn:android --release && yarn ubrn:ios --release", ``` -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: