Incremental build correctness: stale artifacts, destructive renames and undeclared build-phase I/O

Open
#422 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
64/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
cmake, typescript

Research direction

Start with the cleanup TODO in packages/cmake-rn/src/cli.ts, then inspect createFramework in packages/host/src/node/prebuilds/apple.ts and the PBXShellScriptBuildPhase setup in packages/host/src/node/cli/apple.ts. Compare the Apple handling with packages/host/src/node/prebuilds/android.ts. Done means stale outputs are removed, the Apple input remains in the CMake build directory, and the Xcode phase declares its inputs and outputs so unchanged builds can skip it.

Written by the indexing model from the issue text.

Description

Apple 🍎 CMake RN Host 🏡

Three TODOs that individually look like nits but share a cause: the pipeline moves and renames build outputs, and none of the tooling around it knows that.

Stale build artifacts are no longer cleaned

https://github.com/callstackincubator/react-native-node-api/blob/29a527d87fa8cb965b0048b1b4c1cff2b0eab281/packages/cmake-rn/src/cli.ts#L306-L313

The cleanup is commented out with "Consider if this is still important 😬", and its own comment answers the question: it is important because we rename the output files. If a previous build left libfoo.so and the current one produces a differently named artifact, the stale file survives in outputPath and can be picked up downstream. Either restore it, or work out what made it unnecessary and delete the dead code with a note — leaving it commented out means neither.

createFramework renames its input instead of copying

https://github.com/callstackincubator/react-native-node-api/blob/29a527d87fa8cb965b0048b1b4c1cff2b0eab281/packages/host/src/node/prebuilds/apple.ts#L106-L110

fs.promises.rename moves the library out of the CMake build directory and into the framework, then rewrites its install name. From CMake's point of view its own output has vanished, so the next build has to relink — and any second consumer of that artifact finds it missing. Copying costs one file write and makes the step idempotent.

The Android side has the same shape but already copies (prebuilds/android.ts), so this is an inconsistency as much as a bug.

The Xcode build phase declares no inputs or outputs

https://github.com/callstackincubator/react-native-node-api/blob/29a527d87fa8cb965b0048b1b4c1cff2b0eab281/packages/host/src/node/cli/apple.ts#L87-L94

A PBXShellScriptBuildPhase without inputPaths/outputPaths runs on every single build, and Xcode says so in the build log. Declaring them lets Xcode skip the phase when nothing changed — the difference between a no-op incremental build and re-running the addon pipeline on every ⌘B. This one interacts with the two above: declaring outputs is only sound once the artifacts stay where they are claimed to be.

Dominant language
TypeScript
Stars
206
Forks
12
Avg merge
4h 8m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from callstackincubator/react-native-node-api

All issues in callstackincubator/react-native-node-api

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.