diff --git a/change/@react-native-windows-codegen-e4cfdc4a-a4b9-4a36-8902-cc9aa78db21c.json b/change/@react-native-windows-codegen-e4cfdc4a-a4b9-4a36-8902-cc9aa78db21c.json new file mode 100644 index 00000000000..f077c5efef8 --- /dev/null +++ b/change/@react-native-windows-codegen-e4cfdc4a-a4b9-4a36-8902-cc9aa78db21c.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Stop writing codegen files if it just changes new lines", + "packageName": "@react-native-windows/codegen", + "email": "30809111+acoates-ms@users.noreply.github.com", + "dependentChangeType": "patch" +} diff --git a/packages/@react-native-windows/codegen/src/index.ts b/packages/@react-native-windows/codegen/src/index.ts index 507732b8eac..79a7968f520 100644 --- a/packages/@react-native-windows/codegen/src/index.ts +++ b/packages/@react-native-windows/codegen/src/index.ts @@ -109,7 +109,8 @@ function checkFilesForChanges( } const currentContents = fs.readFileSync(fileName, 'utf8'); - if (currentContents !== contents) { + // The current file may be saved using crlf, in which case the new lines may differ from the new output + if (currentContents.replaceAll('\r\n', '\n') !== contents) { console.log(`- ${fileName} has changed`); hasChanges = true; continue; @@ -146,7 +147,8 @@ function writeMapToFiles(map: Map, outputDir: string) { if (fs.existsSync(fileName)) { const currentContents = fs.readFileSync(fileName, 'utf8'); // Don't update the files if there are no changes as this breaks incremental builds - if (currentContents === contents) { + // The current file may be saved using crlf, in which case the new lines may differ from the new output + if (currentContents.replaceAll('\r\n', '\n') === contents) { continue; } }