Freeze current plugins list for "*" option, and remove from README.md (#245)

This commit is contained in:
Andrew Levine 2016-12-06 13:09:36 -06:00 committed by Henry Zhu
parent 4072dfddab
commit 30545e883f
2 changed files with 19 additions and 3 deletions

View File

@ -107,8 +107,6 @@ require("babylon").parse("code", {
### Plugins
> You can use `"*"` to include everything (may be useful in certain cases)
- `jsx`
- `flow`
- `doExpressions`

View File

@ -3,6 +3,19 @@ import { getOptions } from "../options";
import Tokenizer from "../tokenizer";
export const plugins = {};
const frozenDeprecatedWildcardPluginList = [
"jsx",
"doExpressions",
"objectRestSpread",
"decorators",
"classProperties",
"exportExtensions",
"asyncGenerators",
"functionBind",
"functionSent",
"dynamicImport",
"flow"
];
export default class Parser extends Tokenizer {
constructor(options: Object, input: string) {
@ -30,7 +43,11 @@ export default class Parser extends Tokenizer {
}
hasPlugin(name: string): boolean {
return !!(this.plugins["*"] || this.plugins[name]);
if (this.plugins["*"] && frozenDeprecatedWildcardPluginList.indexOf(name) > -1) {
return true;
}
return !!this.plugins[name];
}
extend(name: string, f: Function) {
@ -49,6 +66,7 @@ export default class Parser extends Tokenizer {
}
loadPlugins(pluginList: Array<string>): { [key: string]: boolean } {
// TODO: Deprecate "*" option in next major version of Babylon
if (pluginList.indexOf("*") >= 0) {
this.loadAllPlugins();