Invalidate cache on config and environment variable changes#521
Merged
devongovett merged 3 commits intomasterfrom Jan 10, 2018
Merged
Invalidate cache on config and environment variable changes#521devongovett merged 3 commits intomasterfrom
devongovett merged 3 commits intomasterfrom
Conversation
so they are watched and invalidate the cache
This adds a cacheData object to Assets, and a shouldInvalidate method which accepts a cacheData object to compare. If it returns false, the asset is re-generated. JSAsset uses this to implement environment variable cache invalidation.
For example, if you had a stylus file that was @imported by several parents, only one of them would get recompiled when that file changed. This also affected .babelrc and other config changes, etc.
DeMoorJasper
requested changes
Jan 9, 2018
| this.cacheData.env = {}; | ||
| } | ||
|
|
||
| shouldInvalidate(cacheData) { |
Member
There was a problem hiding this comment.
This causes an error on existing builds (as they already have cache files) and cacheData is undefined in these files.
Member
Author
There was a problem hiding this comment.
hmm yeah, but should be ok with the npm version since the parcel version is part of the cache key right? so when people update parcel, everything will be invalidated already.
Member
There was a problem hiding this comment.
Ow forgot about that, yeah should be fine
DeMoorJasper
approved these changes
Jan 9, 2018
devongovett
added a commit
that referenced
this pull request
Oct 15, 2018
Invalidate cache on config and environment variable changes
devongovett
added a commit
that referenced
this pull request
Oct 15, 2018
Invalidate cache on config and environment variable changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #297. Fixes #66.
This PR does three things:
.babelrc, Parcel will immediately recompile all files that depend on it. Also, if you restart Parcel after making changes, those files will also be recompiled (since Invalidate cache when dependencies included in parent change #514).cacheDataobject to assets, and ashouldInvalidatemethod which accepts a cacheData object to compare. If it returns false, the asset is re-generated. JSAsset uses this to implement environment variable cache invalidation. If your JS file hasprocess.env.MY_ENV, and you changeMY_ENVto a new value, the cache will be invalidated.