[ALOY-1685] Improve incremental build times
DescriptionThe "alloy compile" command is executed on every incremental build, even if no files change. This takes a huge amount of our total build time on incremental builds. Implementing proper incremental build support to only process changed files would be a huge performance gain.
- Hans Knöchel 2020-05-05 This is an absolute must have for Alloy to compete with modern app frameworks. We currently spend around 10-15s for each Alloy compile (only the compile, everything else comes on top) - even if no file changed. Alloy should have a simple file watcher that keeps hashes of every file and only compile them if the hash changed. There is even an [open pull request](https://github.com/appcelerator/alloy/pull/927) for this from one year ago but it seems to have been abandoned since then.
- David Bankier 2020-05-05
This can be implemented really easily with code that has been around since the early days of alloy. TiShadow has been using it for a long time to do fast updates.
Basically just use a file watcher and then you can selectively compile alloy files.
(Personally I use tishadow for all development, but you could create an independant alloy watcher module that would do this very easily.)
alloy compile -b --platform=ios --config sourcemap=false,file=app/controllers/index.js
- Jan Vennemann 2020-05-05
The reason that this is not integrated in the CLI build is that we can't fully rely on the usual NodeJS file watchers like chokidar, since a user can CTRL-C out of the build and then no changes would be tracked anymore. Before the user kicks off a new CLI build he may have edited a couple of other files that we are now unaware of so we would have to do a full Alloy build again.
I tried to address this in https://github.com/appcelerator/alloy/pull/927 but unfortunately i never had the time to finish that. It only watches controllers/views, all other unnecessary processing Alloy does in incremental builds like copying a whole lot of unchanged files around is still happening. The same applies when using the existing
filerestriction flag to selectively compile controllers/views. In the meantime we started working on Webpack support, which will address almost all Alloy incremental build issues. It uses an approach similar to TiShadow, in that it will start a server in the background that keeps running Webpack in watch mode, which will make sure to compile changed files in between CLI builds. The new [alloy-loader](https://github.com/appcelerator/alloy-loader) processes changed controllers/views/styles. Webpack makes sure to only process changed files from other folders as well (like
app/vendor). You can expect to see more of this new build pipeline in the next two weeks.
- David Bankier 2020-05-05 Great! Thanks.