Skip to content

Commit bbf2f20

Browse files
author
Evan Jacobs
committed
fix usage with styled-components babel macro
1 parent 03ab8c7 commit bbf2f20

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils/detectors.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ const VALID_TOP_LEVEL_IMPORT_PATH_MATCHERS = [
55
'styled-components/no-tags',
66
'styled-components/native',
77
'styled-components/primitives',
8-
].map(literal => x => x === literal);
8+
].map(literal => x => x === literal)
99

1010
export const isValidTopLevelImport = (x, state) => {
1111
return [
1212
...VALID_TOP_LEVEL_IMPORT_PATH_MATCHERS,
1313
...useTopLevelImportPathMatchers(state),
14-
].some(isMatch => isMatch(x));
14+
].some(isMatch => isMatch(x))
1515
}
1616

1717
const localNameCache = {}
@@ -23,6 +23,9 @@ export const importLocalName = (name, state, options = {}) => {
2323

2424
if (!bypassCache && cacheKey in localNameCache) {
2525
return localNameCache[cacheKey]
26+
// state.customImportName is injected by the babel macro
27+
} else if (state.customImportName) {
28+
return state.customImportName.name
2629
}
2730

2831
let localName = state.styledRequired

0 commit comments

Comments
 (0)