How to use the @babel/traverse.default.cache function in @babel/traverse

To help you get started, we’ve selected a few @babel/traverse 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 parcel-bundler / parcel / packages / core / parcel-bundler / src / scope-hoisting / hoist.js View on Github external
enter(path, asset) {
      traverse.cache.clearScope();
      path.scope.crawl();

      asset.cacheData.imports = asset.cacheData.imports || Object.create(null);
      asset.cacheData.exports = asset.cacheData.exports || Object.create(null);
      asset.cacheData.wildcards = asset.cacheData.wildcards || [];
      asset.cacheData.sideEffects = asset._package && hasSideEffects(asset);

      let shouldWrap = false;
      path.traverse({
        CallExpression(path) {
          // If we see an `eval` call, wrap the module in a function.
          // Otherwise, local variables accessed inside the eval won't work.
          let callee = path.node.callee;
          if (
            t.isIdentifier(callee) &&
            callee.name === 'eval' &&
github documentationjs / documentation / src / extractors / comments.js View on Github external
addComment(
            data,
            comment.value,
            comment.loc,
            path,
            path.node.loc,
            includeContext
          )
        );
      }

      (path.node[type] || []).filter(isJSDocComment).forEach(parseComment);
    }
  });

  traverse.cache.clear();

  return newResults;
}

@babel/traverse

The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes

MIT
Latest version published 20 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages