How to use the babel-traverse.default.clearCache 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
for (let i = 0; i; i++) {
          let n;
          if (n) {
            return;
          }
          g(() => n);
        }
      }
    `);

    const first = babel.transform(srcTxt, {
      plugins: ["transform-es2015-block-scoping"],
      code: false
    });

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

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

    const expected = unpad(`
      function f(a) {
        var b = function (a) {
          var b = void 0;
          if (b) {
            return {
              v: void 0
            };
          }
          g(() => b);
        };
github babel / minify / packages / babel-plugin-minify-mangle-names / __tests__ / mangler-block-scoping.js View on Github external
let entries = blah();
            entries();
          }
          foo();
        }
        function foo() { }
        module.exports = { bar };
      })();
    `);

    const first = babel.transform(srcTxt, {
      plugins: ["transform-es2015-block-scoping"],
      code: false
    });

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

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

    const expected = unpad(`
      (function () {
        function a() {
          if (smth) {
            var a = blah();
            a();
          }
          b();
        }
        function b() {}
        module.exports = { bar: a };