Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit a896c60

Browse files
committed
feat: support _cacheGroup
1 parent 750bcc2 commit a896c60

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/lib/setupContext.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const { isBuffer } = require('util')
2525
let contextMap = sharedState.contextMap
2626
let configContextMap = sharedState.configContextMap
2727
let contextSourcesMap = sharedState.contextSourcesMap
28+
let configHashMap = sharedState.configHashMap
2829
let env = sharedState.env
2930

3031
// Earmarks a directory for our touch files.
@@ -629,6 +630,8 @@ function setupContext(configOrPath) {
629630
let [tailwindConfig, userConfigPath, tailwindConfigHash] = getTailwindConfig(configOrPath)
630631
let isConfigFile = userConfigPath !== null
631632

633+
const { _cacheGroup = 'default', _hash } = tailwindConfig
634+
632635
let contextDependencies = new Set()
633636

634637
// If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
@@ -656,8 +659,13 @@ function setupContext(configOrPath) {
656659
if (!contextDependenciesChanged) {
657660
// If this file already has a context in the cache and we don't need to
658661
// reset the context, return the cached context.
659-
if (isConfigFile && contextMap.has(sourcePath)) {
660-
return contextMap.get(sourcePath)
662+
if (contextMap.has(sourcePath)) {
663+
if (
664+
isConfigFile ||
665+
(_hash && configHashMap.has(_cacheGroup) && _hash === configHashMap.get(_cacheGroup))
666+
) {
667+
return contextMap.get(sourcePath)
668+
}
661669
}
662670

663671
// If the config used already exists in the cache, return that.
@@ -669,6 +677,10 @@ function setupContext(configOrPath) {
669677
}
670678
}
671679

680+
if (_hash) {
681+
configHashMap.set(_cacheGroup, _hash)
682+
}
683+
672684
// If this source is in the context map, get the old context.
673685
// Remove this source from the context sources for the old context,
674686
// and clean up that context if no one else is using it. This can be

src/lib/sharedState.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ module.exports = {
99
contextMap: new Map(),
1010
configContextMap: new Map(),
1111
contextSourcesMap: new Map(),
12+
configHashMap: new Map(),
1213
contentMatchCache: new LRU({ maxSize: 25000 }),
1314
}

0 commit comments

Comments
 (0)