fix(core): keep the external-core stager CRLF-safe - #322
Open
jhodges10 wants to merge 1 commit into
Open
Conversation
On a Windows checkout Git ships core.autocrlf=true and this repository
carries no .gitattributes, so every source lands in the working tree with
CRLF. The stager splits its inputs on "\n" and then makes line-shaped
decisions about them, which leaves a trailing CR that a `$`-anchored
terminator or an exact-equality compare no longer matches.
Transform 4 fails hardest. Its terminator scan never matches, so the first
alias it means to drop reads as an unterminated multi-line declaration,
`skipping` latches on and never clears, and the remainder of the static
@native-sdk/core restatement is dropped from the stage. The build does not
fail there; it fails much later, and blames the SDK:
error SC0001: Module '"./sdk/core.ts"' has no exported member 'Cmd'.
Every TypeScript-core app is unbuildable on Windows as a result — the
staged surface is truncated at the first deduped alias, taking Cmd and Sub
with it. Transform 3's Bytes-alias folding fails the same way, quietly
keeping the alias it exists to remove.
Tolerate the optional CR in all three guards. This is a no-op on LF input,
so the staged bytes the compiled-core batteries pin against the transpiler
lane are unchanged, and the fixture twin in tests/compiled-core needs no
matching edit.
Add .gitattributes so the working tree is LF on every platform. This
repository reads its own sources byte-exactly in several places, so a CRLF
checkout does not fail loudly, it changes build output. The index is
already all-LF, so this changes checkout behavior only; third_party keeps
its upstream bytes, since the WebView2 headers are committed CRLF.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@jhodges10 is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
@ctate I get the impression based on this and the fact there's only a single example that declares Window support that it's a bit of a lower priority right now 😆! I'm prototyping a video editor to see how far I can get so I'm focused on cross-platform compatibility from the start, so you'll probably see quite a few more PR's from me re: Windows support. |
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.
The bug
Every TypeScript-core app fails to build on Windows, and the error blames the SDK rather than the stager that caused it:
Git for Windows installs with
core.autocrlf=trueand this repository carries no.gitattributes, so a Windows checkout lands every source in the working tree with CRLF.stage_external_core.mjssplits its inputs on"\n"and then makes line-shaped decisions about them, which leaves a trailing CR that a$-anchored terminator or an exact-equality compare no longer matches.Transform 4 fails hardest. Its terminator scan matches nothing, so the first alias it means to drop reads as an unterminated multi-line declaration,
skippinglatches on and never clears, and the remainder of the static@native-sdk/corerestatement is dropped from the stage —CmdandSubwith it.Concretely, staging
packages/core/compile-surface/core.tsforexamples/voice-memo: 25,543 bytes in, 2,995 out, truncated at line 90. The alias that trips it is single-line and ends in;:It is correctly terminated. Only the CR makes it read otherwise.
Transform 3's Bytes-alias folding fails the same way —
line !== "export type Uint8Array = Uint8Array;"never matches — quietly keeping the alias it exists to remove.The fix
Tolerate the optional CR in all three guards. This is a no-op on LF input, so the staged bytes the compiled-core batteries pin byte-identical against the transpiler lane are unchanged, and the fixture twin in
tests/compiled-core/build_core.shneeds no matching edit — it runs under POSIX shell on LF inputs..gitattributes
Added so the working tree is LF on every platform. This repository reads its own sources byte-exactly in more places than most — the staged tree, the compiled-core output pins, the pinned goldens, and the POSIX shell the gate and CI scripts run under — so a CRLF checkout does not fail loudly, it changes build output. The regex fix addresses one symptom; this closes the class.
It is a safe addition: the index is already all-LF, so
git add --renormalize .after adding it produces zero churn.third_party/**is marked-textbecause the WebView2 headers Microsoft ships are committed CRLF.Happy to split this into its own PR if you would rather take the stager fix alone.
Tests
packages/core/test/stage_external_core.test.tsstages a fixture under both line endings and asserts the surface survives past a deduped alias, the dedupe still happens, the Bytes fold still happens, and CRLF staging agrees with LF staging line for line.Against the unpatched stager the three CRLF cases fail and every LF case passes — which is also the evidence that the fix changes nothing on LF:
With the fix, all 7 pass.
npm testinpackages/coreis 140/143; the 3 failures are indocs_samplesand reproduce identically on unpatchedmainon this machine.Verified end to end by building
examples/voice-memoon Windows, which now produceszig-out/bin/voice-memo.exe.🤖 Generated with Claude Code