You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was testing out ferric-cli, just with the ferric-example it seems to generate a big .so file just for android. In this case it were 6.1mb.
I suppose this can negatively affect the final build size of RN apps.
Is there a way or if possible, could you add rust flags to the CLI, or whatever that it can be done to help reduce size of the native generated file(s), .so or otherwise?
> ferric build --configuration release
╭─────────────────────────╮
│░█▀▀░█▀▀░█▀▄░█▀▄░▀█▀░█▀▀░│
│░█▀▀░█▀▀░█▀▄░█▀▄░░█░░█░░░│
│░▀░░░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀░│
╰─────────────────────────╯
ℹ Using default targets, pass --android, --apple or individual --target options, to avoid this.
Using cargo 1.88.0 (873a06493 2025-05-10)
✖ Failed to build: Expected /react-native-node-api/packages/ferric-example/target/x86_64-linux-android/release to exist
Could be that the bug is that you are passing release and not --release to cargo build, so it's only generating the debug folder.
❯ ll target/x86_64-linux-android/
Octal Permissions Links Size User Group Date Modified Git Name
0755 drwxr-xr-x 1 - user user 24 jul 12:40 -I debug/
0644 .rw-r--r-- 1 177 user user 24 jul 12:40 -I CACHEDIR.TAG
It seems encapsulated, perhaps if you had a flag to show all the actual commands being run in the background, through logging.
Also add a .toLowerCase() because, Release do not work.
With those settings, I was able to get a Hello World Node-API module down to 304 KB for iOS or macOS (can't remember). Can't be sure what size that might mean for Android, however.
In the init/generate command, do you prefer that it provide a package.json to be a standalone lib or can it be as the idea I had, you suggest the scripts as in the previous comment, then that package import the lib from the dist/ in the actual project?
In the init/generate command, do you prefer that it provide a package.json to be a standalone lib or can it be as the idea I had, you suggest the scripts as in the previous comment, then that package import the lib from the dist/ in the actual project?
Sorry, not quite clear what you mean. Could you illustrate the two alternatives?
1- Not a standalone package, without a package.json. But, managed by the package.json root of the app. Where the root package as suggested #196 (comment) managed as if it were an additional like android or ios.
Activity
[-]Reduce native .so files size[/-][+]Reduce native files size[/+]kraenhansen commentedon Jul 24, 2025
I'd be happy to add anything to reduce the file size - got any concrete ideas in mind?
Notice that the current default
--configurationis "Debug" and you'll likely get a smaller binary if you pass--configuration Releaseto ferric.I know that there are also possibilities of shaving off size with link-time optimization (LTO) when building the final app.
dougg0k commentedon Jul 24, 2025
I suggested the repo which already should contain all the possible ways. Whichever you choose and works.
Maybe leave
Releaseas default?dougg0k commentedon Jul 24, 2025
Could be that the bug is that you are passing
releaseand not--releasetocargo build, so it's only generating the debug folder.It seems encapsulated, perhaps if you had a flag to show all the actual commands being run in the background, through logging.
Also add a
.toLowerCase()because,Releasedo not work.shirakaba commentedon Jul 24, 2025
Various common tricks for reducing binary size include these Cargo build settings:
With those settings, I was able to get a Hello World Node-API module down to 304 KB for iOS or macOS (can't remember). Can't be sure what size that might mean for Android, however.
dougg0k commentedon Jul 24, 2025
I checked, for android, it was reduced to ~330kb.
In
packages/ferric-examplenpm run buildcargo build --releasemv target/release target/x86_64-linux-android/npm run buildif the script has--configuration releasedougg0k commentedon Jul 24, 2025
Maybe
ferric-exampleshouldnotexist. But be generated by theferric-cli, that wayCargo.tomland other files could be better managed.Then suggest
#195
dougg0k commentedon Jul 24, 2025
If I am able to finish this PR, there should be plenty of improvements added.
#200 - List inside.
dougg0k commentedon Jul 26, 2025
In the init/generate command, do you prefer that it provide a package.json to be a standalone lib or can it be as the idea I had, you suggest the scripts as in the previous comment, then that package import the lib from the dist/ in the actual project?
#206
shirakaba commentedon Jul 26, 2025
Sorry, not quite clear what you mean. Could you illustrate the two alternatives?
dougg0k commentedon Jul 26, 2025
1- Not a standalone package, without a package.json. But, managed by the package.json root of the app. Where the root package as suggested #196 (comment) managed as if it were an additional like android or ios.
2- With a package.json to be a standalone lib.
dougg0k commentedon Jul 27, 2025
I took the with second approach. Let me know if you preferred the first.
I think I am done with the PRs, feel free to review them.
I will probably wait for them to maybe get merged and released before using the tool.
I will close this issue as done. Added through one of the PRs.