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 babel / minify / packages / babel-plugin-minify-mangle-names / __tests__ / mangler-block-scoping.js View on Github external
(function(){
        (function() {
          for (let x in y) y[x];
          f(() => { g() });
        })();
        function g() {}
      })();
    `);

    const ast = babel.transform(source, {
      presets: ["env"],
      sourceType: "script",
      code: false
    }).ast;

    (traverse.clearCache || traverse.cache.clear)();

    const actual = babel.transformFromAst(ast, null, {
      sourceType: "script",
      plugins: [require("../src/index")]
    }).code;

    const expected = unpad(`
      "use strict";

      (function () {
        (function () {
          for (var b in y) {
            y[b];
          }f(function () {
            a();
          });