Building project on Windows

I have been trying to build version v6.0.17 on my Windows machine with node v16.1.0 and have encountered a number of issues. It seems clear the build only supports a non windows environment and this should at least be documented somewhere.

It does not properly create component directories on windows. I worked past this by updating fs-extra to create directories recursively using the recursive option to mkdirSync instead of the custom implementation.

In build-core-js.js It attempts to create a child process using a format that is incompatible with the windows shell it spawns. It tries to use the format “ENVVAR=value npx…” which is not compatible with the CMD shell that is created on windows. This happens even if I am currently running a /sh compatible shell as it always creates a CMD shell based on the process.platform. I had to monkey patch exec-sh to return sh on windows so I could continue.

A number of places, notably in my case build-core-js, the code directly concatonates in the result of a path.resolve into an exec command, which does not work on windows because paths contain \ characters. I noticed this also would break if there were spaces in the path.

To work around this I also had to update get-output to replace \ with / as well as updating any further calls to path.resolve, like in build-core-js.

After I made all these changes and I was able to successfully execute npm run build-core:prod

Overall it is clear there are way too many exec calls used in the build scripts. Some of them are used in places where there are convenient node alternatives and might benefit from some refactoring(build-clear.js). It is also using way more sync calls than necessary especially since async await is already used in a subset of files.