i made the javascripts faster with a transformer prepass to check what transformers actually have to be ran
This commit is contained in:
@@ -9,6 +9,7 @@ var transform = require("./transformation");
|
||||
var generate = require("./generation");
|
||||
var defaults = require("lodash/object/defaults");
|
||||
var contains = require("lodash/collection/contains");
|
||||
var traverse = require("./traverse");
|
||||
var clone = require("./helpers/clone");
|
||||
var Scope = require("./traverse/scope");
|
||||
var util = require("./util");
|
||||
@@ -352,6 +353,8 @@ File.prototype.transform = function (ast) {
|
||||
modFormatter.init();
|
||||
}
|
||||
|
||||
this.checkNode(ast);
|
||||
|
||||
var astRun = function (key) {
|
||||
each(self.transformerStack, function (pass) {
|
||||
pass.astRun(key);
|
||||
@@ -367,6 +370,30 @@ File.prototype.transform = function (ast) {
|
||||
astRun("exit");
|
||||
};
|
||||
|
||||
var checkTransformerVisitor = {
|
||||
enter: function (node, parent, scope, context, state) {
|
||||
state.check(node, scope);
|
||||
}
|
||||
};
|
||||
|
||||
File.prototype.checkNode = function (node, scope) {
|
||||
var self = this;
|
||||
scope = scope || this.scope;
|
||||
|
||||
var check = function (node, scope) {
|
||||
each(self.transformerStack, function (pass) {
|
||||
if (pass.shouldRun) return;
|
||||
pass.checkNode(node, scope);
|
||||
});
|
||||
};
|
||||
|
||||
check(node, scope);
|
||||
|
||||
traverse(node, checkTransformerVisitor, scope, {
|
||||
check: check
|
||||
});
|
||||
};
|
||||
|
||||
File.prototype.generate = function () {
|
||||
var opts = this.opts;
|
||||
var ast = this.ast;
|
||||
|
||||
Reference in New Issue
Block a user