Skip to content

Commit b1dcfda

Browse files
ensure a cache miss (#283)
Co-authored-by: Evan Jacobs <[email protected]>
1 parent 4187ada commit b1dcfda

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils/detectors.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const VALID_TOP_LEVEL_IMPORT_PATHS = [
44
'styled-components/native',
55
'styled-components/primitives',
66
]
7+
const CACHE_MISS = Symbol('CACHE_MISS');
78

89
export const isValidTopLevelImport = x =>
910
VALID_TOP_LEVEL_IMPORT_PATHS.includes(x)
@@ -13,15 +14,15 @@ const localNameCache = {}
1314
export const importLocalName = (name, state, bypassCache = false) => {
1415
const cacheKey = name + state.file.opts.filename
1516

16-
if (!bypassCache && cacheKey in localNameCache) {
17+
if (!bypassCache && cacheKey in localNameCache && localNameCache[cacheKey] !== CACHE_MISS) {
1718
return localNameCache[cacheKey]
1819
}
1920

2021
let localName = state.styledRequired
2122
? name === 'default'
2223
? 'styled'
2324
: name
24-
: false
25+
: CACHE_MISS
2526

2627
state.file.path.traverse({
2728
ImportDeclaration: {

0 commit comments

Comments
 (0)