Only export methods and not the entire cache
This commit is contained in:
parent
fc19ac2af5
commit
d5e78384ef
@ -5,6 +5,7 @@ import * as visitors from "./visitors";
|
||||
import * as messages from "babel-messages";
|
||||
import includes from "lodash/collection/includes";
|
||||
import * as t from "babel-types";
|
||||
import * as cache from "./cache";
|
||||
|
||||
export { default as NodePath } from "./path";
|
||||
export { default as Scope } from "./scope";
|
||||
@ -39,7 +40,6 @@ traverse.explode = visitors.explode;
|
||||
traverse.NodePath = require("./path");
|
||||
traverse.Scope = require("./scope");
|
||||
traverse.Hub = require("./hub");
|
||||
traverse.cache = require("./cache");
|
||||
|
||||
traverse.cheap = function (node, enter) {
|
||||
if (!node) return;
|
||||
@ -88,7 +88,7 @@ traverse.clearNode = function (node) {
|
||||
if (key[0] === "_" && node[key] != null) node[key] = undefined;
|
||||
}
|
||||
|
||||
traverse.cache.path.delete(node);
|
||||
cache.path.delete(node);
|
||||
|
||||
let syms: Array<Symbol> = Object.getOwnPropertySymbols(node);
|
||||
for (let sym of syms) {
|
||||
@ -127,3 +127,13 @@ traverse.hasType = function (tree: Object, scope: Object, type: Object, blacklis
|
||||
|
||||
return state.has;
|
||||
};
|
||||
|
||||
traverse.clearCache = function() {
|
||||
cache.clear();
|
||||
};
|
||||
|
||||
traverse.copyCache = function(source, destination) {
|
||||
if (cache.path.has(source)) {
|
||||
cache.path.set(destination, cache.path.get(source));
|
||||
}
|
||||
};
|
||||
|
||||
@ -404,11 +404,8 @@ export function inherits(child, parent) {
|
||||
}
|
||||
|
||||
t.inheritsComments(child, parent);
|
||||
traverse.copyCache(parent, child);
|
||||
|
||||
const pathCache = traverse.cache.path;
|
||||
if (pathCache.has(parent)) {
|
||||
pathCache.set(child, pathCache.get(parent));
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user