From 704311934654a92a011eee03b5c605a717ca7c84 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 29 Apr 2015 01:13:23 +0100 Subject: [PATCH] fix PluginManager --- src/babel/transformation/file/index.js | 2 +- src/babel/transformation/file/plugin-manager.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/babel/transformation/file/index.js b/src/babel/transformation/file/index.js index 1bcf55b3a8..709d68beeb 100644 --- a/src/babel/transformation/file/index.js +++ b/src/babel/transformation/file/index.js @@ -219,7 +219,7 @@ export default class File { // init plugins! var beforePlugins = []; var afterPlugins = []; - var pluginManager = new PluginManager(this.transformers, beforePlugins, afterPlugins); + var pluginManager = new PluginManager(this, this.transformers, beforePlugins, afterPlugins); for (var i = 0; i < file.opts.plugins.length; i++) { pluginManager.add(file.opts.plugins[i]); } diff --git a/src/babel/transformation/file/plugin-manager.js b/src/babel/transformation/file/plugin-manager.js index 57f4bfd853..4d5b9aa242 100644 --- a/src/babel/transformation/file/plugin-manager.js +++ b/src/babel/transformation/file/plugin-manager.js @@ -1,4 +1,5 @@ import * as messages from "../../messages"; +import * as util from "../../util"; export default class PluginManager { static memoisedPlugins = []; @@ -17,8 +18,9 @@ export default class PluginManager { return transformer; } - constructor(transformers, before, after) { + constructor(file, transformers, before, after) { this.transformers = transformers; + this.file = file; this.before = before; this.after = after; } @@ -90,7 +92,7 @@ export default class PluginManager { this.validate(plugin); // build! - var pass = this.transformers[key] = plugin.buildPass(this); + var pass = this.transformers[plugin.key] = plugin.buildPass(this.file); if (pass.canTransform()) { var stack = position === "before" ? this.before : this.after; stack.push(pass);