Repository navigation
feat(metadata): add ns metadata trim - #6203
Draft
NathanWalker wants to merge 2 commits into
Draft
NathanWalker wants to merge 2 commits into
NathanWalker wants to merge 2 commits into
Conversation
…n app uses Analyzes an app's emitted JavaScript with the runtime's own tools and generates metadata for what it references plus the types those depend on. On Apple platforms the result can be embedded into a copy of NativeScript.framework, shrinking the binary. On Android it writes the whitelist Gradle consumes with -PnsFilterMetadata.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Declared rules are merged with what the bundle analysis finds, following the same whitelist-plugins-usages semantics as ns prepare. Projects are read automatically for iOS and Android; other hosts pass --native-api-usage.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
ns metadata trim, which reduces native API metadata to what an app's emitted JavaScript uses, plus the types those APIs depend on.It builds on metadata filtering rather than replacing it:
native-api-usage.jsonrules from the app and its plugins are merged with what the analysis finds.The command is host-neutral. It takes a bundle path, so it doesn't assume a NativeScript project layout. Scope, how it works and how other hosts adopt it are in the RFC: NativeScript/rfcs#62.
Related fix on the generator: NativeScript/runtimes@cb26a2b.
Evidence
Run on a TSX app embedding NativeScript in
nsh: macOS 26, iOS 26.5 simulator, Android 16 emulator. Not yet run on physical devices or against a standardnsproject.npx vitest run: 2167 passed, 9 skipped, including new tests for the Mach-O rewrite and both toolchains.native-api-usage.jsonon a project fixture: the app'swhitelistandblacklistand a plugin'susesall reach the generator, andwhitelist-plugins-usages: falsedrops the plugin's entry.usesentry addsWebViewand ablacklistentry removesBuild.VERSION. Blacklisting a type a kept API needs fails the build and names it.Merge Danger
Door: two-way
Additive. It introduces one new command, with its options scoped to that command. Nothing calls it from
prepareorbuild.Blast Radius: additive
Only people who run the new command are affected. A trimmed app that reaches an API the analysis can't see fails at run time in that code path, which is why this is opt-in and the RFC covers the rollout.