xnr
Version:
Easily, quickly and reliably run a Node.js script from the CLI.
38 lines (37 loc) • 1.62 kB
TypeScript
import { Options as AcornOptions, Program } from "acorn";
import { Options as SucraseOptions_ } from "sucrase";
export type Method = "import" | "require";
export type KnownExtension = "js" | "ts" | "jsx" | "tsx" | "cjs" | "cts" | "mjs" | "mts";
export declare const getKnownExt: (filePath: string) => KnownExtension | undefined;
export declare class XnrError extends Error {
constructor(message: string);
}
export declare const prettyPath: (filePath: string) => string;
export declare const parseModule: (code: string, options?: AcornOptions) => Program;
export declare const findClosestPackageJson: (absFilePath: string) => string | undefined;
export declare const determineModuleType: (absFilePath: string) => Method;
export declare const isNodeBuiltin: (rawImport: string) => boolean;
export declare const escapeRegExp: (str: string) => string;
export declare const stripAnsi: (string: string) => string;
export declare const getNpmPackageFromImport: (importPath: string) => string | undefined;
export declare const isExternalDependency: (importPath: string) => boolean;
export type SucraseOptions = Omit<SucraseOptions_, "transforms" | "filePath">;
export type LocalDependency = {
type: "local";
method: Method;
raw: string;
file: SourceFileNode;
};
export type ExternalDependency = {
type: "external";
method: Method;
path: string;
package: string;
};
export type Dependency = LocalDependency | ExternalDependency;
export type SourceFileNode = {
path: string;
ast: Program;
localDependencies: LocalDependency[];
externalDependencies: ExternalDependency[];
};