6.0.0
I'm extremely stupid and didn't commit as I go. To anyone reading this I'm extremely sorry. A lot of these changes are very broad and I plan on releasing Babel 6.0.0 today live on stage at Ember Camp London so I'm afraid I couldn't wait. If you're ever in London I'll buy you a beer (or assorted beverage!) to make up for it, also I'll kiss your feet and give you a back massage, maybe.
This commit is contained in:
@@ -4,8 +4,6 @@ import { reservedWords } from "../util/identifier";
|
||||
import { getOptions } from "../options";
|
||||
import Tokenizer from "../tokenizer";
|
||||
|
||||
// Registered plugins
|
||||
|
||||
export const plugins = {};
|
||||
|
||||
export default class Parser extends Tokenizer {
|
||||
@@ -14,12 +12,10 @@ export default class Parser extends Tokenizer {
|
||||
super(options, input);
|
||||
|
||||
this.options = options;
|
||||
this.inModule = this.options.sourceType === "module";
|
||||
this.isReservedWord = reservedWords[6];
|
||||
this.input = input;
|
||||
this.loadPlugins(this.options.plugins);
|
||||
|
||||
// Figure out if it's a module code.
|
||||
this.inModule = this.options.sourceType === "module";
|
||||
this.plugins = this.loadPlugins(this.options.plugins);
|
||||
|
||||
// If enabled, skip leading hashbang line.
|
||||
if (this.state.pos === 0 && this.input[0] === "#" && this.input[1] === "!") {
|
||||
@@ -27,20 +23,31 @@ export default class Parser extends Tokenizer {
|
||||
}
|
||||
}
|
||||
|
||||
hasFeature(name: string): boolean {
|
||||
return !!this.options.features[name];
|
||||
hasPlugin(name: string): boolean {
|
||||
return !!(this.plugins["*"] || this.plugins[name]);
|
||||
}
|
||||
|
||||
extend(name: string, f: Function) {
|
||||
this[name] = f(this[name]);
|
||||
}
|
||||
|
||||
loadPlugins(plugins) {
|
||||
for (let name in plugins) {
|
||||
let plugin = exports.plugins[name];
|
||||
if (!plugin) throw new Error(`Plugin '${name}' not found`);
|
||||
plugin(this, plugins[name]);
|
||||
loadPlugins(plugins: Array<string>) {
|
||||
let pluginMap = {};
|
||||
|
||||
if (plugins.indexOf("flow") >= 0) {
|
||||
// ensure flow plugin loads last
|
||||
plugins.splice(plugins.indexOf("flow"), 1);
|
||||
plugins.push("flow");
|
||||
}
|
||||
|
||||
for (let name of plugins) {
|
||||
pluginMap[name] = true;
|
||||
|
||||
let plugin = exports.plugins[name];
|
||||
if (plugin) plugin(this);
|
||||
}
|
||||
|
||||
return pluginMap;
|
||||
}
|
||||
|
||||
parse(): {
|
||||
|
||||
Reference in New Issue
Block a user