Fix `build`, `lint`, and (most) `test` targets on Windows
Summary
Right now, a fresh clone of this repository does not work on Windows under either PowerShell or cmd prompts. This is due to some simple reasons (OS-specific path concatenation), and some tricky ones (Windows filesystems' "junction points" are incompatible with how current eslint walks symlinks). This pull request addresses critical issues that prevented the project from being built and tested on Windows environments. The primary goal was to ensure cross-platform compatibility for the build scripts and resolve related test failures, thereby unblocking contributions from developers on Windows platforms.
Details
The core of this PR is fixing the build process on Windows. Previously, running yarn build would fail due to a combination of non-portable code in build scripts and issues with how the TypeScript composite build handled incremental builds on Windows. Additionally, several snapshot tests were failing due to differences in filesystem ordering between inode-derived file systems and Windows.
This PR introduces the following fixes:
- Cross-Platform Build Scripts: The main build script (build.js) has been updated to normalize file paths, allowing it to correctly find and transpile TypeScript files on Windows.
- Stable TypeScript Builds: the
build-clean-allscript now properly cleans out stale TypeScript build information (.tsbuildinfofiles) along with build artifacts. This resolves persistent issues with the composite build failing incorrectly even when making fixes to the build script/infra. - Stabilized Snapshot Tests: Tests that rely on reading directory contents now explicitly sort the results. This ensures that Jest snapshots are consistent across all operating systems, regardless of the underlying filesystem's default ordering.
- Upgraded
execafor Security and Compatibility: Theexecapackage was upgraded to the latest version. This not only improves cross-platform command execution, particularly on Windows, but highlighted a latent typo (utf-8versusutf8), and also resolves latent security vulnerabilities related to command injection.
A Note on Remaining Test Failures
While this PR fixes the build and a specific class of test failures, a number of unrelated unit and end-to-end tests are still failing. These failures appear to be pre-existing and are not further regressions on Windows caused by these changes.
On Windows, we disable a lint error that relates to workspace resolution. These failures appear to be an issue with how eslint processes project files when they are symbolic links (junction points on Windows file system). This led to incorrect file resolution during linting. This appears to be a known issue within the ecosystem, with developers reporting similar behavior in other contexts.
To keep this pull request focused on the critical task of unblocking the build, I'm deferrinf the fix for the few remaining test failures in a separate, follow-up effort. This allows us to merge the foundational build fixes quickly and enables developers on all platforms to contribute to fixing the remaining issues. Until all relevant tests are passing and Windows CI is introduced, I don't know that we should advertise Windows support in the docs. I'm open to feedback on this aspect.
Test Plan
On Windows:
yarn lint
yarn build
yarn test (still some failures, but starting point was zero tests passing)
Checklist
- [x] Documentation is up to date.
- [ ] Follows commit message convention described in CONTRIBUTING.md.
- [ ] For functional changes, my test plan has linked these CLI changes into a local
react-nativecheckout (instructions).