EOL characters in compiled files in Windows vs Mac

Should the EOL characters in generated files (.bs.js in my case) be the same for both Mac and Windows?

I was discussing a project recently with someone on Windows (I’m on Mac) and noticed that after running the ReScript compiler on their machine, VSCode was indicating that the generated .bs.js had changed. A visual spot check in the diff tool did not show any differences so I’m currently assuming it’s the end of line characters.

Unfortunately I don’t have access to a Windows machine at the moment, so just checking if anyone else has seen different EOL characters on Windows compared to Mac.

This is on rescript@9.1.4.

Thanks

The ReScript printer currently always emits \n newlines. If you don’t use the printer and have your editor output windows line endings, there might be a discrepancy

1 Like

Here’s an update on this for anyone who encounters this same problem.

Not sure if I have this 100% accurate, but it’s my current understanding.

Git has a config setting core.autocrlf

On Windows, the default setting converts LF in source repositories to CRLF locally, and then back to LF when committing.

The ReScript compiler creates files with LF only line endings.

On Windows, Git reports this as a difference, expecting to see CRLF.

The solution was to create a .gitattributes file with the following content:

* text=auto
*.res text eol=lf
*.bs.js text eol=lf

For reference:

1 Like