/
PluginOptions.js
90 lines (72 loc) 路 1.94 KB
/
PluginOptions.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// @flow
import type {
BuildMode,
EnvMap,
FilePath,
LogLevel,
PluginOptions as IPluginOptions,
ServerOptions,
HMROptions,
DetailedReportOptions,
} from '@parcel/types';
import type {FileSystem} from '@parcel/fs';
import type {PackageManager} from '@parcel/package-manager';
import type {ParcelOptions} from '../types';
let parcelOptionsToPluginOptions: WeakMap<ParcelOptions, PluginOptions> =
new WeakMap();
export default class PluginOptions implements IPluginOptions {
#options /*: ParcelOptions */;
constructor(options: ParcelOptions): PluginOptions {
let existing = parcelOptionsToPluginOptions.get(options);
if (existing != null) {
return existing;
}
this.#options = options;
parcelOptionsToPluginOptions.set(options, this);
return this;
}
get instanceId(): string {
return this.#options.instanceId;
}
get mode(): BuildMode {
return this.#options.mode;
}
get env(): EnvMap {
return this.#options.env;
}
get hmrOptions(): ?HMROptions {
return this.#options.hmrOptions;
}
get serveOptions(): ServerOptions | false {
return this.#options.serveOptions;
}
get shouldBuildLazily(): boolean {
return this.#options.shouldBuildLazily;
}
get shouldAutoInstall(): boolean {
return this.#options.shouldAutoInstall;
}
get logLevel(): LogLevel {
return this.#options.logLevel;
}
get cacheDir(): FilePath {
// TODO: remove this. Probably bad if there are other types of caches.
// Maybe expose the Cache object instead?
return this.#options.cacheDir;
}
get projectRoot(): FilePath {
return this.#options.projectRoot;
}
get inputFS(): FileSystem {
return this.#options.inputFS;
}
get outputFS(): FileSystem {
return this.#options.outputFS;
}
get packageManager(): PackageManager {
return this.#options.packageManager;
}
get detailedReport(): ?DetailedReportOptions {
return this.#options.detailedReport;
}
}