From bbf2f206e1ff1aa40f943eed9ada39cf15dd7015 Mon Sep 17 00:00:00 2001 From: Evan Jacobs Date: Tue, 22 Feb 2022 15:25:55 -0500 Subject: [PATCH] fix usage with styled-components babel macro --- src/utils/detectors.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/detectors.js b/src/utils/detectors.js index a4a02dc..834b77f 100644 --- a/src/utils/detectors.js +++ b/src/utils/detectors.js @@ -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 = {} @@ -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