js-slang
Version:
Javascript-based implementations of Source, written in Typescript
32 lines (31 loc) • 1.14 kB
TypeScript
import type es from 'estree';
import type { Context } from '../..';
import type { FileGetter } from '../moduleTypes';
import { type ImportResolutionOptions } from './resolver';
export type LinkerResult = {
ok: false;
verboseErrors: boolean;
} | {
ok: true;
programs: Record<string, es.Program>;
files: Record<string, string>;
sourceModulesToImport: Set<string>;
topoOrder: string[];
verboseErrors: boolean;
};
export type LinkerOptions = {
resolverOptions: ImportResolutionOptions;
};
export declare const defaultLinkerOptions: LinkerOptions;
/**
* Starting from the entrypoint file, parse all imported local modules and create
* a dependency graph.
*
* @param fileGetter A function that, when given a file path, either returns the contents
* of that file as a string, or if it doesn't exist, `undefined`
*/
export default function parseProgramsAndConstructImportGraph(fileGetter: FileGetter, entrypointFilePath: string, context: Context, options: Partial<{
resolverOptions: Partial<{
extensions: string[] | null;
}>;
}> | undefined, shouldAddFileName: boolean): Promise<LinkerResult>;