Browse Source

ignore object props, make private annotations non-enumerable

contingency-plan
Rich-Harris 10 years ago
parent
commit
6589b5b094
  1. 23
      src/ast/analyse.js

23
src/ast/analyse.js

@ -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 ] ) {

Loading…
Cancel
Save