Skip to content

Commit

Permalink
fix usage with styled-components babel macro
Browse files Browse the repository at this point in the history
  • Loading branch information
quantizor committed Feb 22, 2022
1 parent 03ab8c7 commit bbf2f20
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/detectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const VALID_TOP_LEVEL_IMPORT_PATH_MATCHERS = [
'styled-components/no-tags',
'styled-components/native',
'styled-components/primitives',
].map(literal => x => x === literal);
].map(literal => x => x === literal)

export const isValidTopLevelImport = (x, state) => {
return [
...VALID_TOP_LEVEL_IMPORT_PATH_MATCHERS,
...useTopLevelImportPathMatchers(state),
].some(isMatch => isMatch(x));
].some(isMatch => isMatch(x))
}

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

if (!bypassCache && cacheKey in localNameCache) {
return localNameCache[cacheKey]
// state.customImportName is injected by the babel macro
} else if (state.customImportName) {
return state.customImportName.name
}

let localName = state.styledRequired
Expand Down

0 comments on commit bbf2f20

Please sign in to comment.