Close two test gaps: unverified prebuild Info.plist and a missing .node fixture - #448
Closed
kraenhansen wants to merge 1 commit into
Closed
Close two test gaps: unverified prebuild Info.plist and a missing .node fixture#448kraenhansen wants to merge 1 commit into
kraenhansen wants to merge 1 commit into
Conversation
…de fixture verify-prebuilds.mts now parses each Apple framework's Info.plist and asserts CFBundleExecutable/CFBundleIdentifier match what writeFrameworkInfoPlist wrote, instead of skipping the file. The Babel plugin test for "does not touch required JS files" now includes a sibling my-addon.apple.node next to my-addon.js, so the assertion is exercised rather than vacuously true. That exposed a real bug: isNodeApiModule didn't check whether a same-named .js/.cjs/.mjs/.json file would already satisfy the require() before ever considering a .node prebuild, so the plugin could rewrite a require() call that Node's own resolution would never route to the addon. Fixed to defer to a colliding source file, matching Node's own module resolution order. Closes #424
Collaborator
Author
|
Closing this in favor of #450, which builds on @wanxiankai's earlier #426 (the first PR to fix #424) plus the same improvements this PR made (moving the fix into Generated by Claude Code |
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.
Closes #424.
verify-prebuildsnow reads theInfo.plistit findsverifyApplePrebuildused tocontinuepastInfo.plistwithout reading it. It now parses it with@expo/plist(already a dependency elsewhere in the repo) and asserts:CFBundleExecutablematches the framework's library name (the.frameworkdirectory's basename)CFBundleIdentifiermatchesescapeBundleIdentifier("com.callstackincubator.node-api.<libraryName>")— the defaultwriteFrameworkInfoPlist(packages/host/src/node/prebuilds/apple.ts) writes when no--apple-bundle-identifieris passed, which is hownode-addon-examplesbuildsescapeBundleIdentifieris now exported from the package's publicnodeentrypoint so the verify script (areact-native-node-apiconsumer, same as any addon author) can import it rather than re-deriving the escaping rule.The Babel plugin test now proves its own claim — and that found a real bug
"and does not touch required JS files" asserted the plugin leaves
require('./my-addon')alone, but the fixture had nomy-addon.*.nodefor the plugin to have found in the first place — the assertion passed for the wrong reason. Adding a siblingmy-addon.apple.node(as theTODOasked) makes the test exercise real precedence between a.jsfile and a same-named addon, and it failed:isNodeApiModuledidn't check whether a same-named.js/.cjs/.mjs/.jsonfile would already satisfyrequire()before considering.nodeprebuilds, so the plugin rewrote a call that Node's own resolution would never route to the addon.Fixed
isNodeApiModuleto defer to a colliding source file when the module path has no explicit.nodeextension, matching Node's own resolution order (.js/.jsonbefore.node). Explicitrequire('./my-addon.node')calls are untouched by this check, since there's no resolution ambiguity to defer to.Verification
pnpm run build,pnpm run lint,pnpm exec prettier --checkcleanpackages/host's test suite: thepluginandescapeBundleIdentifiersuites pass in full; the only failures are 4 pre-existing permission-based tests that fail in this sandbox because it runs as root (verified they fail identically onnextbefore this change)verifyFrameworkInfoPlistagainst a realInfo.plistwritten bycreateAppleFramework(install_name_toolisn't available on Linux, so I read the file straight after it's written) — both the pass and the mismatch-detection path behave as expected@react-native-node-api/node-addon-examples: it's privatecc @kraenhansen for review.