inject transformer parser plugins
This commit is contained in:
parent
276cafaae1
commit
0e7fd0741d
@ -392,7 +392,13 @@ export default class File {
|
||||
|
||||
var transformers = parseOpts.transformers = {};
|
||||
for (var key in this.transformers) {
|
||||
transformers[key] = this.transformers[key].canParse;
|
||||
var transformer = this.transformers[key];
|
||||
|
||||
transformers[key] = transformer.canTransform;
|
||||
|
||||
if (transformer.parser) {
|
||||
parseOpts.plugins[key] = true;
|
||||
}
|
||||
}
|
||||
|
||||
parseOpts.looseModules = this.isLoose("es6.modules");
|
||||
|
||||
@ -3,6 +3,7 @@ import isFunction from "lodash/lang/isFunction";
|
||||
import traverse from "../traversal";
|
||||
import isObject from "lodash/lang/isObject";
|
||||
import assign from "lodash/object/assign";
|
||||
import acorn from "../../../../acorn";
|
||||
import File from "./file";
|
||||
import each from "lodash/collection/each";
|
||||
|
||||
@ -24,6 +25,7 @@ export default class Transformer {
|
||||
|
||||
this.manipulateOptions = take("manipulateOptions");
|
||||
this.metadata = take("metadata") || {};
|
||||
this.parser = take("parser");
|
||||
this.check = take("check");
|
||||
this.post = take("post");
|
||||
this.pre = take("pre");
|
||||
@ -31,6 +33,10 @@ export default class Transformer {
|
||||
this.handlers = this.normalize(transformer);
|
||||
this.opts ||= {};
|
||||
this.key = transformerKey;
|
||||
|
||||
if (this.parser) {
|
||||
acorn.plugins[key] = this.parser(acorn.Parser.prototype, acorn.tokTypes);
|
||||
}
|
||||
}
|
||||
|
||||
normalize(transformer: Object): Object {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user