forked from babel/babel
/
plugin.ts
37 lines (30 loc) 路 1.04 KB
/
plugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { finalize } from "./helpers/deep-array";
import type { ReadonlyDeepArray } from "./helpers/deep-array";
import type { PluginObject } from "./validation/plugins";
export default class Plugin {
key: string | undefined | null;
manipulateOptions?: (options: unknown, parserOpts: unknown) => void;
post?: PluginObject["post"];
pre?: PluginObject["pre"];
visitor: PluginObject["visitor"];
parserOverride?: Function;
generatorOverride?: Function;
options: {};
externalDependencies: ReadonlyDeepArray<string>;
constructor(
plugin: PluginObject,
options: {},
key?: string,
externalDependencies: ReadonlyDeepArray<string> = finalize([]),
) {
this.key = plugin.name || key;
this.manipulateOptions = plugin.manipulateOptions;
this.post = plugin.post;
this.pre = plugin.pre;
this.visitor = plugin.visitor || {};
this.parserOverride = plugin.parserOverride;
this.generatorOverride = plugin.generatorOverride;
this.options = options;
this.externalDependencies = externalDependencies;
}
}