UNPKG

1.16 kBTypeScriptView Raw
1import type { HubInterface, Scope, Visitor } from '@babel/traverse';
2import { NodePath } from '@babel/traverse';
3import type { File, Program } from '@babel/types';
4import type { Importer, ImportPath } from './importer/index.js';
5import type { TransformOptions } from '@babel/core';
6export default class FileState {
7 #private;
8 opts: TransformOptions;
9 path: NodePath<Program>;
10 ast: File;
11 scope: Scope;
12 code: string;
13 hub: HubInterface;
14 constructor(options: TransformOptions, { code, ast, importer }: {
15 code: string;
16 ast: File;
17 importer: Importer;
18 });
19 /**
20 * Try to resolve and import the ImportPath with the `name`
21 */
22 import(path: ImportPath, name: string): NodePath | null;
23 /**
24 * Parse the content of a new file
25 * The `filename` is required so that potential imports inside the content can be correctly resolved and
26 * the correct babel config file could be loaded. `filename` needs to be an absolute path.
27 */
28 parse(code: string, filename: string): FileState;
29 traverse<S>(visitors: Visitor<S>, state?: S): void;
30 traverse(visitors: Visitor): void;
31}