From aa9b3ec2a8803e0779d1196666348e72b615d60e Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Fri, 15 Jan 2016 19:00:38 -0800 Subject: [PATCH 1/2] Make Babylon correctly handle "flow" being present multiple times in plugins. --- packages/babylon/src/parser/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babylon/src/parser/index.js b/packages/babylon/src/parser/index.js index a9882ff30a..1a0227fd4e 100644 --- a/packages/babylon/src/parser/index.js +++ b/packages/babylon/src/parser/index.js @@ -36,7 +36,7 @@ export default class Parser extends Tokenizer { if (plugins.indexOf("flow") >= 0) { // ensure flow plugin loads last - plugins.splice(plugins.indexOf("flow"), 1); + plugins = plugins.filter(plugin => plugin !== "flow"); plugins.push("flow"); } From af363c8da56dc3c2a1274914739763fdc5177861 Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Fri, 15 Jan 2016 19:29:21 -0800 Subject: [PATCH 2/2] Make babylon ignore duplicate plugins. --- packages/babylon/src/parser/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/babylon/src/parser/index.js b/packages/babylon/src/parser/index.js index 1a0227fd4e..1440ea1a41 100644 --- a/packages/babylon/src/parser/index.js +++ b/packages/babylon/src/parser/index.js @@ -41,10 +41,12 @@ export default class Parser extends Tokenizer { } for (let name of plugins) { - pluginMap[name] = true; + if (!pluginMap[name]) { + pluginMap[name] = true; - let plugin = exports.plugins[name]; - if (plugin) plugin(this); + let plugin = exports.plugins[name]; + if (plugin) plugin(this); + } } return pluginMap;