perf(caching): improves caching of loader and optimizer #464
+67
−22
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 PR contains a:
Motivation / Use-Case
1. Performance refactor / race-condition fix:
This PR eliminates the race condition where the loader or optimizer may do the same processing (same transformation on the same image) redundantly if the same file transformation's loader is triggered more than once before the first transformation has finished.
2. Fix
npm start
Didn't work before; now it does. (With as little change to the prior scripts as possible.)
Breaking Changes
None that I'm aware of.
Additional Info
This PR doesn't eliminate all possible such race conditions, namely if the same image transformation occurs between the loader and the minimizer, because the transformers are different functions (because the minimizer functionality is different than the generator/loader, even though the underlying operation is the same), it's still possible to have redundant image transformations if one transformation happens via the loader, and the same transformation happens via the webpack optimize hook.