Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
31 lines
750 B
Plaintext
31 lines
750 B
Plaintext
import { addDefault, addNamed } from '@babel/helper-module-imports'
|
|
|
|
export function addImport(
|
|
state,
|
|
importSource /*: string */,
|
|
importedSpecifier /*: string */,
|
|
nameHint /* ?: string */
|
|
) {
|
|
let cacheKey = ['import', importSource, importedSpecifier].join(':')
|
|
if (state[cacheKey] === undefined) {
|
|
let importIdentifier
|
|
if (importedSpecifier === 'default') {
|
|
importIdentifier = addDefault(state.file.path, importSource, { nameHint })
|
|
} else {
|
|
importIdentifier = addNamed(
|
|
state.file.path,
|
|
importedSpecifier,
|
|
importSource,
|
|
{
|
|
nameHint
|
|
}
|
|
)
|
|
}
|
|
state[cacheKey] = importIdentifier.name
|
|
}
|
|
return {
|
|
type: 'Identifier',
|
|
name: state[cacheKey]
|
|
}
|
|
}
|