Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return through.obj(function (row, enc, cb) {
if (!row.esm) {
cb(null, row);
return;
}
var ast = acorn.parse(row.source, { sourceType: 'module' });
assignParent(ast);
scan.analyze(ast);
var scope = scan.scope(ast);
var esmDefaultName = '_esmDefault'
var patches = [];
ast.body.forEach(function (node) {
if (node.type === 'ExportDefaultDeclaration') {
if (node.declaration.id) {
esmDefaultName = node.declaration.id.name
}
patches.push({
start: node.start,
end: node.declaration.start,
string: node.declaration.id ? '' : 'var _esmDefault = '
});
}