fix(build): copy assets from tsdown so the build works on Windows - #1253
fix(build): copy assets from tsdown so the build works on Windows#1253anhtahaylove wants to merge 2 commits into
Conversation
The build script chained POSIX file utilities after tsdown. npm runs scripts through cmd.exe on Windows, which has no cp or mkdir -p, so the tail failed with "The system cannot find the path specified." and "The syntax of the command is incorrect." The four leading copies were guarded with || true, but mkdir -p dist/viewer and the two copies after it were not, so npm run build exited 1 and dist/viewer/ was never created — the viewer assets silently went missing from the package. Move the copies into tsdown's own copy option, which runs in Node and needs no shell. The copy rides on the last hook entry rather than every mapped block: setting it on all of them runs the copies once per entry, and the parallel copies race each other (EBUSY unlinking dist/ iii-config.yaml on Windows). Verified on Windows 11 with an empty dist/: exit 0, all six assets present, and each byte-identical to its source. Three consecutive builds stay at exit 0, and dist/ still carries 12 bundles, 14 hooks, and 15 plugin scripts. Test suite is unchanged at 30 failed | 1665 passed, matching main on the same machine. Signed-off-by: anhtahaylove <everest.kill1@gmail.com>
|
@anhtahaylove is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe build script now runs ChangesBuild asset handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The build now copies required assets through the existing build tool instead of shell-specific commands, addressing Windows build failures while preserving the existing package outputs. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
|
@rohitg00 — small one, ready when you are.
This moves the asset copying into tsdown's own Worth flagging one non-obvious detail: Verified: builds clean three times in a row (exit 0, stable 12 bundles / 14 hooks / 15 plugin scripts), all six assets sha256-identical to source, |
The build failure this fixes is silent in CI on Linux: the POSIX tail worked there, so nothing caught that cmd.exe could not run it. These assert the shape the fix depends on — copies on exactly one block, no cp/mkdir left in the script, and every packaged asset actually copied. Restoring the old script and dropping the copy block fails four of six. Signed-off-by: anhtahaylove <everest.kill1@gmail.com>
npm run buildexits 1 on Windows, anddist/viewer/never gets created — so the viewer assets are silently missing from the built package.The script chains POSIX file utilities after
tsdown:npm runs scripts through
cmd.exeon Windows, which has neithercpnormkdir -p:The four leading copies survive because of their
|| trueguards, soiii-config.yamland friends do land.mkdir -p dist/viewerand the two copies after it have no guard, so the chain dies there and takes the exit code with it.Easy to miss two ways:
✔ Build completeis printed before the failure, and piping the build throughtail/grepreports the pipeline's last exit status rather than npm's.What this does
Moves the copies into tsdown's own
copyoption, which runs in Node and needs no shell. No new dependency — tsdown 0.21.10 already supports it.The copy rides on the last hook entry rather than every mapped block. Setting it on all of them runs the copies once per entry, and the parallel copies race:
clean: trueonly runs on the first config block, so assets copied from the last one are not wiped.Verification
Windows 11, Node v24.19.0, starting from an empty
dist/:Byte-identical to source, not merely present. Three consecutive builds without cleaning also stay at exit 0, and the outputs are unchanged: 12 bundles in
dist/, 14 indist/hooks/, 15 inplugin/scripts/.package.jsonfilesalready shipsdist/, so packaging is unaffected.Test suite is 30 failed | 1665 passed, identical to
mainat e04ba88 on this machine — the pre-existing failures are unrelated and unaffected.This should be a no-op on Linux and macOS, where the old chain already worked. Worth a CI check on a Windows runner if you want it guarded, though I did not want to add a workflow uninvited.
Found while working on #1249; unrelated to it, so it is a separate PR.
Summary by CodeRabbit
Bug Fixes
Chores