1 |
|
2 |
|
3 | import type {
|
4 | BuildMode,
|
5 | BundleGroup,
|
6 | Engines,
|
7 | EnvironmentContext,
|
8 | EnvMap,
|
9 | File,
|
10 | FilePath,
|
11 | Glob,
|
12 | JSONObject,
|
13 | LogLevel,
|
14 | Meta,
|
15 | ModuleSpecifier,
|
16 | PackageName,
|
17 | PackageJSON,
|
18 | ReporterEvent,
|
19 | ResolvedParcelConfigFile,
|
20 | Semver,
|
21 | ServerOptions,
|
22 | SourceLocation,
|
23 | Stats,
|
24 | Symbol,
|
25 | TargetSourceMapOptions,
|
26 | ConfigResult,
|
27 | OutputFormat,
|
28 | TargetDescriptor,
|
29 | } from '@parcel/types';
|
30 |
|
31 | import type {FileSystem} from '@parcel/fs';
|
32 | import type Cache from '@parcel/cache';
|
33 | import type {PackageManager} from '@parcel/package-manager';
|
34 |
|
35 | export type Environment = {|
|
36 | context: EnvironmentContext,
|
37 | engines: Engines,
|
38 | includeNodeModules:
|
39 | | boolean
|
40 | | Array<PackageName>
|
41 | | {[PackageName]: boolean, ...},
|
42 | outputFormat: OutputFormat,
|
43 | isLibrary: boolean,
|
44 | |};
|
45 |
|
46 | export type Target = {|
|
47 | distEntry?: ?FilePath,
|
48 | distDir: FilePath,
|
49 | env: Environment,
|
50 | sourceMap?: TargetSourceMapOptions,
|
51 | name: string,
|
52 | publicUrl: ?string,
|
53 | loc?: ?SourceLocation,
|
54 | |};
|
55 |
|
56 | export type Dependency = {|
|
57 | id: string,
|
58 | moduleSpecifier: ModuleSpecifier,
|
59 | isAsync: boolean,
|
60 | isEntry: boolean,
|
61 | isOptional: boolean,
|
62 | isURL: boolean,
|
63 | isWeak: ?boolean,
|
64 | isDeferred: boolean,
|
65 | loc: ?SourceLocation,
|
66 | env: Environment,
|
67 | meta: Meta,
|
68 | target: ?Target,
|
69 | sourceAssetId: ?string,
|
70 | sourcePath: ?string,
|
71 | symbols: Map<Symbol, Symbol>,
|
72 | pipeline?: ?string,
|
73 | |};
|
74 |
|
75 | export type Asset = {|
|
76 | id: string,
|
77 | hash: ?string,
|
78 | filePath: FilePath,
|
79 | type: string,
|
80 | dependencies: Map<string, Dependency>,
|
81 | includedFiles: Map<FilePath, File>,
|
82 | isIsolated: boolean,
|
83 | isInline: boolean,
|
84 | isSplittable: ?boolean,
|
85 | isSource: boolean,
|
86 | outputHash: string,
|
87 | env: Environment,
|
88 | meta: Meta,
|
89 | stats: Stats,
|
90 | contentKey: ?string,
|
91 | mapKey: ?string,
|
92 | pipeline: ?string,
|
93 | symbols: Map<Symbol, Symbol>,
|
94 | sideEffects: boolean,
|
95 | uniqueKey?: ?string,
|
96 | |};
|
97 |
|
98 | export type ParcelOptions = {|
|
99 | entries: Array<FilePath>,
|
100 | rootDir: FilePath,
|
101 | config?: ResolvedParcelConfigFile,
|
102 | defaultConfig?: ResolvedParcelConfigFile,
|
103 | env: EnvMap,
|
104 | targets: ?(Array<string> | {+[string]: TargetDescriptor, ...}),
|
105 | defaultEngines?: Engines,
|
106 |
|
107 | disableCache: boolean,
|
108 | cacheDir: FilePath,
|
109 | killWorkers?: boolean,
|
110 | mode: BuildMode,
|
111 | minify: boolean,
|
112 | scopeHoist: boolean,
|
113 | sourceMaps: boolean,
|
114 | hot: boolean,
|
115 | serve: ServerOptions | false,
|
116 | autoinstall: boolean,
|
117 | logLevel: LogLevel,
|
118 | projectRoot: FilePath,
|
119 | lockFile: ?FilePath,
|
120 | profile: boolean,
|
121 | patchConsole: boolean,
|
122 |
|
123 | inputFS: FileSystem,
|
124 | outputFS: FileSystem,
|
125 | cache: Cache,
|
126 | packageManager: PackageManager,
|
127 | |};
|
128 |
|
129 | export type NodeId = string;
|
130 |
|
131 | export type Edge<TEdgeType: string | null> = {|
|
132 | from: NodeId,
|
133 | to: NodeId,
|
134 | type: TEdgeType,
|
135 | |};
|
136 |
|
137 | export interface Node {
|
138 | id: string;
|
139 | +type?: string;
|
140 |
|
141 | value: any;
|
142 | }
|
143 |
|
144 | export type AssetNode = {|id: string, +type: 'asset', value: Asset|};
|
145 |
|
146 | export type DependencyNode = {|
|
147 | id: string,
|
148 | type: 'dependency',
|
149 | value: Dependency,
|
150 | complete?: boolean,
|
151 | |};
|
152 |
|
153 | export type RootNode = {|id: string, +type: 'root', value: string | null|};
|
154 |
|
155 | export type AssetRequestDesc = {|
|
156 | filePath: FilePath,
|
157 | env: Environment,
|
158 | sideEffects?: boolean,
|
159 | code?: string,
|
160 | pipeline?: ?string,
|
161 | |};
|
162 |
|
163 | export type AssetRequestResult = {|
|
164 | assets: Array<Asset>,
|
165 | configRequests: Array<{|request: ConfigRequestDesc, result: Config|}>,
|
166 | |};
|
167 |
|
168 | export type AssetGroup = AssetRequestDesc;
|
169 | export type AssetGroupNode = {|
|
170 | id: string,
|
171 | +type: 'asset_group',
|
172 |
|
173 | value: AssetGroup,
|
174 | deferred: boolean,
|
175 | |};
|
176 |
|
177 | export type DepPathRequestNode = {|
|
178 | id: string,
|
179 | +type: 'dep_path_request',
|
180 | value: Dependency,
|
181 | |};
|
182 |
|
183 | export type AssetRequestNode = {|
|
184 | id: string,
|
185 | +type: 'asset_request',
|
186 | value: AssetRequestDesc,
|
187 | |};
|
188 |
|
189 | export type EntrySpecifierNode = {|
|
190 | id: string,
|
191 | +type: 'entry_specifier',
|
192 | value: ModuleSpecifier,
|
193 | |};
|
194 |
|
195 | export type Entry = {|
|
196 | filePath: FilePath,
|
197 | packagePath?: FilePath,
|
198 | |};
|
199 |
|
200 | export type EntryFileNode = {|
|
201 | id: string,
|
202 | +type: 'entry_file',
|
203 | value: Entry,
|
204 | |};
|
205 |
|
206 | export type AssetGraphNode =
|
207 | | AssetGroupNode
|
208 | | AssetNode
|
209 | | DependencyNode
|
210 | | EntrySpecifierNode
|
211 | | EntryFileNode
|
212 | | RootNode;
|
213 |
|
214 | export type BundleGraphNode =
|
215 | | AssetNode
|
216 | | DependencyNode
|
217 | | EntrySpecifierNode
|
218 | | EntryFileNode
|
219 | | RootNode
|
220 | | BundleGroupNode
|
221 | | BundleNode;
|
222 |
|
223 | export type ConfigRequestNode = {|
|
224 | id: string,
|
225 | +type: 'config_request',
|
226 | value: ConfigRequestDesc,
|
227 | |};
|
228 |
|
229 | export type Config = {|
|
230 | isSource: boolean,
|
231 | searchPath: FilePath,
|
232 | env: Environment,
|
233 | resolvedPath: ?FilePath,
|
234 | resultHash: ?string,
|
235 | result: ConfigResult,
|
236 | includedFiles: Set<FilePath>,
|
237 | pkg: ?PackageJSON,
|
238 | watchGlob: ?Glob,
|
239 | devDeps: Map<PackageName, ?string>,
|
240 | shouldRehydrate: boolean,
|
241 | shouldReload: boolean,
|
242 | shouldInvalidateOnStartup: boolean,
|
243 | |};
|
244 |
|
245 | export type ConfigRequestDesc = {|
|
246 | filePath: FilePath,
|
247 | env: Environment,
|
248 | isSource: boolean,
|
249 | pipeline?: ?string,
|
250 | plugin?: PackageName,
|
251 | meta: JSONObject,
|
252 | |};
|
253 |
|
254 | export type DepVersionRequestNode = {|
|
255 | id: string,
|
256 | +type: 'dep_version_request',
|
257 | value: DepVersionRequestDesc,
|
258 | |};
|
259 |
|
260 | export type DepVersionRequestDesc = {|
|
261 | moduleSpecifier: PackageName,
|
262 | resolveFrom: FilePath,
|
263 | result?: Semver,
|
264 | |};
|
265 |
|
266 | export type EntryRequest = {|
|
267 | specifier: ModuleSpecifier,
|
268 | result?: FilePath,
|
269 | |};
|
270 |
|
271 | export type EntryRequestNode = {|
|
272 | id: string,
|
273 | +type: 'entry_request',
|
274 | value: string,
|
275 | |};
|
276 |
|
277 | export type TargetRequestNode = {|
|
278 | id: string,
|
279 | +type: 'target_request',
|
280 | value: FilePath,
|
281 | |};
|
282 |
|
283 | export type CacheEntry = {|
|
284 | filePath: FilePath,
|
285 | env: Environment,
|
286 | hash: string,
|
287 | assets: Array<Asset>,
|
288 |
|
289 | initialAssets: ?Array<Asset>,
|
290 | |};
|
291 |
|
292 | export type Bundle = {|
|
293 | id: string,
|
294 | type: string,
|
295 | env: Environment,
|
296 | entryAssetIds: Array<string>,
|
297 | isEntry: ?boolean,
|
298 | isInline: ?boolean,
|
299 | isSplittable: ?boolean,
|
300 | target: Target,
|
301 | filePath: ?FilePath,
|
302 | name: ?string,
|
303 | pipeline: ?string,
|
304 | stats: Stats,
|
305 | |};
|
306 |
|
307 | export type BundleNode = {|
|
308 | id: string,
|
309 | +type: 'bundle',
|
310 | value: Bundle,
|
311 | |};
|
312 |
|
313 | export type BundleGroupNode = {|
|
314 | id: string,
|
315 | +type: 'bundle_group',
|
316 | value: BundleGroup,
|
317 | |};
|
318 |
|
319 | export type TransformationOpts = {|
|
320 | request: AssetRequestDesc,
|
321 | options: ParcelOptions,
|
322 | |};
|
323 |
|
324 | export type ValidationOpts = {|
|
325 | request: AssetRequestDesc,
|
326 | options: ParcelOptions,
|
327 | |};
|
328 |
|
329 | export type ReportFn = (event: ReporterEvent) => void;
|