|
|
@ -38,18 +38,16 @@ export default function analyse ( ast, magicString, module ) { |
|
|
|
let previous = 0; |
|
|
|
|
|
|
|
ast.body.forEach( statement => { |
|
|
|
statement._defines = {}; |
|
|
|
statement._modifies = {}; |
|
|
|
statement._dependsOn = {}; |
|
|
|
statement._imported = false; |
|
|
|
|
|
|
|
// link back to the module
|
|
|
|
statement._module = module; |
|
|
|
Object.defineProperties( statement, { |
|
|
|
_defines: { value: {} }, |
|
|
|
_modifies: { value: {} }, |
|
|
|
_dependsOn: { value: {} }, |
|
|
|
_imported: { value: false, writable: true }, |
|
|
|
_module: { value: module }, |
|
|
|
_source: { value: magicString.snip( previous, statement.end ) } |
|
|
|
}); |
|
|
|
|
|
|
|
// store the actual code, for easy regeneration
|
|
|
|
statement._source = magicString.snip( previous, statement.end ); |
|
|
|
previous = statement.end; |
|
|
|
|
|
|
|
currentTopLevelStatement = statement; // so we can attach scoping info
|
|
|
|
|
|
|
|
walk( statement, { |
|
|
@ -132,6 +130,11 @@ export default function analyse ( ast, magicString, module ) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// disregard the `bar` in { bar: foo }
|
|
|
|
if ( parent.type === 'Property' && node !== parent.value ) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const definingScope = scope.findDefiningScope( node.name ); |
|
|
|
|
|
|
|
if ( ( !definingScope || definingScope.depth === 0 ) && !statement._defines[ node.name ] ) { |
|
|
|