Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function handleReference(node, name, keypath) {
let mod = modulesMap.get(keypath);
if (mod && !imports.has(name) && !scope.contains(name)) {
if (typeof mod === 'string') mod = [mod, 'default'];
// prevent module from importing itself
if (mod[0] === id) return false;
const hash = `${keypath}:${mod[0]}:${mod[1]}`;
const importLocalName =
name === keypath ? name : makeLegalIdentifier(`$inject_${keypath}`);
if (!newImports.has(hash)) {
if (mod[1] === '*') {
newImports.set(hash, `import * as ${importLocalName} from '${mod[0]}';`);
} else {
newImports.set(hash, `import { ${mod[1]} as ${importLocalName} } from '${mod[0]}';`);
}
}
if (name !== keypath) {
magicString.overwrite(node.start, node.end, importLocalName, {
storeName: true
});
}
return true;
node.right.properties.forEach((prop) => {
if (prop.computed || !('key' in prop) || prop.key.type !== 'Identifier') return;
const { name } = prop.key;
if (name === makeLegalIdentifier(name)) namedExports[name] = true;
});
return;
const keys = Object.keys(data).filter((key) => key === makeLegalIdentifier(key));
const code = `var data = ${toSource(data)};\n\n`;