Repository navigation
[heft-sass-plugin] Make the incremental cache file name machine-independent - #6212
Open
Heramb_Inamke (HerambInamke) wants to merge 1 commit into
Open
Heramb_Inamke (HerambInamke) wants to merge 1 commit into
Heramb_Inamke (HerambInamke) wants to merge 1 commit into
Conversation
…endent The cache file name was a hash of all processor options, including the absolute build folder, other absolute paths, and the core count. Exclude the logger and concurrency from the hash and make absolute paths relative to the build folder. Fixes microsoft#6126
|
Heramb_Inamke (@HerambInamke) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This branch has not been deployed
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.
Summary
Fixes #6126.
The incremental cache file written by
@rushstack/heft-sass-plugin(temp/build/sass/sass_<hash>.json) got a different name on each machine, because the name came from hashing every processor option. That included the absolute build folder, other absolute folder paths, andconcurrency(the core count). Identical builds in different checkout folders, or on machines with different core counts, produced different output folder listings and different build cache entries.This PR makes the name depend only on options that affect the output.
Details
Root cause:
SassProcessor.loadCacheAsynccomputed the name asgetContentsHash('sass.json', JSON.stringify({ version: 2, options })). Theoptionsobject fromSassPluginholdsbuildFolder, absolutesrcFolder/dtsOutputFolders/cssOutputFolders/loadPaths,concurrency = numberOfCores, and thelogger.Fix: the
JSON.stringifycall that builds the hash input now uses a replacer. It:loggerandconcurrency, which do not affect the output;buildFolder, using forward slashes, sobuildFolderitself and every folder under it give the same text on any machine and OS.Options that do affect the output (for example
exportAsDefault, file extensions, output folders relative to the project) still change the name, so the cache is still invalidated when they change.Safety of sharing the file across machines: the old name also stopped a cache file from another checkout from ever being loaded. The cache contents are already portable: each record stores
relativePath(relative tobuildFolder) plus content-derivedversion/cssVersionhashes, and the paths are resolved against the currentbuildFolderon load. So a cache file restored from another machine is valid.Compatibility: this is not a breaking change. The first build after upgrading writes a cache file under the new name and does a full Sass compile. The old
sass_<oldhash>.jsonfile stays intemp/until it is cleaned, as with any earlier option change.I also considered a fixed file name with the options hash stored inside the file. I chose the smaller change, which keeps the existing scheme.
How it was tested
New unit tests in
src/test/SassProcessor.test.ts(loadCacheAsync):concurrencydiffers (4 vs 16).exportAsDefault).The first test fails without the fix and passes with it.
Commands run:
Follow-up issues created: none.