Use browserify cache when bundling #844
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This work is heavily inspired by uber-watchify https://github.com/benbria/uber-watchify which I found I could not use directly, so I used a lot of its code as inspiration
Browserify provides the possibility of using a cache which greatly speeds the generation of the bundled files. This cache is for example used if we use watchify and re-bundle a file which has been updated. But this cache is not persisted so it is not used when we start tests from scratch. If the tests to bundle are complicated, with a lot of common files, this bundling of all tests can take a long time (was taking almost a minute in our case when bundling the whole test suite to run headlessly)
We can take advantage of this cache by saving it to a file once the target has been bundled and reading it from this file when we need to bundle the target again. By doing this, bundling our whole test suite was down to less that 10 seconds
There are a couple of things that we need to add to make this work:
Apart from that I fixed that even if the
watchForFileChanges
setting was false, it would still activate watchifyIncludes unit tests. I was not really sure how to add integration tests or e2e tests so it does not include them