[Babylon] Take the first set of options for plugins (#7994)

* [Babylon] Take the first set of options for plugins

* Fix test

* Docs
This commit is contained in:
Nicolò Ribaudo
2018-05-24 17:54:32 +02:00
committed by Logan Smyth
parent 555ee80f43
commit 6eab6f5863
3 changed files with 53 additions and 3 deletions

View File

@@ -33,8 +33,8 @@ export default class Parser extends StatementParser {
function pluginsMap(plugins: PluginList): PluginsMap {
const pluginMap: PluginsMap = (Object.create(null): Object);
for (const plugin of plugins) {
if (Array.isArray(plugin)) pluginMap[plugin[0]] = plugin[1] || {};
else pluginMap[plugin] = {};
const [name, options = {}] = Array.isArray(plugin) ? plugin : [plugin, {}];
if (!pluginMap[name]) pluginMap[name] = options || {};
}
return pluginMap;
}