Cache parsed imports for faster and incremental build #2746
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 is related to this discussion:
#2640
I propose an experimental option to use imports caching.
This is experimental because it is insecure regarding to
@import (multiple)
according to @seven-phases-maxHowever, for most less users, this setting will be enough secure to leverage better productivity in a development environment.
Because many don't use
@import (multiple)
it would be a bad to not benefits from these perf gains just for features we don't always use.If the user does not use these options then nothing would change for him. I recommend only using this in a dev mode setting (why the option!)
New render options
render
can be called with options:The cache, by default, will be empty at the beginning of a render, so that modified files between 2 renders will always be reloaded. However this simple trick divides the compilation time by 2 on my app and someone else too.
With this additional option, the next compilations will be faster because the cache will already be filled, and compilation time is divided by 3.
However the user has to call
less.invalidateImportsCacheFile
himself everytime a less file change.This could probably be simpler to use if less supported some kind of watch mode (like watchify for browserify)
Exemple gulp integration