How to use the scope-analyzer.analyze function in scope-analyzer

To help you get started, we’ve selected a few scope-analyzer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github browserify / browser-pack / esm.js View on Github external
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 = '
        });
      }

scope-analyzer

simple scope analysis for javascript ASTs

Apache-2.0
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis