UNPKG

@wessberg/cjs-to-esm-transformer

Version:

A Custom Transformer for Typescript that transforms Node-style CommonJS to tree-shakeable ES Modules

43 lines 1.44 kB
import * as TS from "typescript"; interface ResolveOptions { id: string; parent: string | null | undefined; moduleDirectory?: string; prioritizedPackageKeys?: string[]; prioritizedExtensions?: string[]; readFile(fileName: string, encoding?: string): string | undefined; fileExists(fileName: string): boolean; } /** * A map between id's and their results from previous resolving * @type {Map<string, string|undefined>} */ /** * A map between id's and their results from previous resolving * @type {Map<string, string|undefined>} */ /** * A map between id's and their results from previous resolving * @type {Map<string, string|undefined>} */ interface CjsToEsmOptions { typescript?: typeof TS; debug?: boolean | string | ((file: string) => boolean); readFile?: ResolveOptions["readFile"]; fileExists?: ResolveOptions["fileExists"]; } /** * CustomTransformer that converts CommonJS to tree-shakeable ESM * * @param [options] * @returns */ declare function cjsToEsm(options?: CjsToEsmOptions): TS.CustomTransformers; /** * A TransformerFactory that converts CommonJS to tree-shakeable ESM * * @param [options] * @returns */ declare function cjsToEsmTransformerFactory({ fileExists, readFile, debug, typescript, ...rest }?: CjsToEsmOptions): TS.TransformerFactory<TS.SourceFile>; export { CjsToEsmOptions, cjsToEsm, cjsToEsmTransformerFactory }; //# sourceMappingURL=index.d.ts.map