BridgeJS: Skip writing output files when content is unchanged#639
Merged
krodak merged 1 commit intoswiftwasm:mainfrom Feb 16, 2026
Merged
Conversation
kateinoigakukun
approved these changes
Feb 16, 2026
Member
kateinoigakukun
left a comment
There was a problem hiding this comment.
It makes sense to me, thanks!
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.
Overview
BridgeJSTool writes
BridgeJS.swiftandBridgeJS.jsonon every invocation, even when the content hasn't changed. The atomic write creates a new temp file each time, which updates the mtime and makes SPM think the output changed. This triggers a recompile ofBridgeJS.swiftand a relink on every build, even with zero source changes.Reproducing
While testing cross-plugin builds after #638, we noticed
Compiling Khasm BridgeJS.swiftandLinking KhasmWasm.wasmin every no-op build. Traced it to the unconditional.write(to:atomically:)calls inBridgeJSTool- the content was identical but the file got a new timestamp every time.To reproduce with any BridgeJS project:
Fix
Compare content before writing. If the existing file has identical content, skip the write.
Applied to both
BridgeJS.swiftandBridgeJS.json. The--always-writeflag still works - it controls whether the file gets created at all (even when empty), just doesn't force a rewrite when content matches.Question
Was the unconditional write intentional? Wondering if there's an edge case I'm not seeing, if so, lets just close this one 🙏🏻