tsconfig-paths
- Version 4.2.0
- Published
- 216 kB
- 3 dependencies
- MIT license
Install
npm i tsconfig-paths
yarn add tsconfig-paths
pnpm add tsconfig-paths
Overview
Load node modules according to tsconfig paths, in run-time or via API.
Index
Functions
Interfaces
Type Aliases
Functions
function createMatchPath
createMatchPath: ( absoluteBaseUrl: string, paths: { [key: string]: string[] }, mainFields?: (string | string[])[], addMatchAll?: boolean) => MatchPath;
Creates a function that can resolve paths according to tsconfig paths property.
Parameter absoluteBaseUrl
Absolute version of baseUrl as specified in tsconfig.
Parameter paths
The paths as specified in tsconfig.
Parameter mainFields
A list of package.json field names to try when resolving module files. Select a nested field using an array of field names.
Parameter addMatchAll
Add a match-all "*" rule if none is present
Returns
a function that can resolve paths.
function createMatchPathAsync
createMatchPathAsync: ( absoluteBaseUrl: string, paths: { [key: string]: string[] }, mainFields?: (string | string[])[], addMatchAll?: boolean) => MatchPathAsync;
See the sync version for docs.
function loadConfig
loadConfig: (cwd?: string) => ConfigLoaderResult;
function matchFromAbsolutePaths
matchFromAbsolutePaths: ( absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>, requestedModule: string, readJson?: Filesystem.ReadJsonSync, fileExists?: Filesystem.FileExistsSync, extensions?: Array<string>, mainFields?: (string | string[])[]) => string | undefined;
Finds a path from tsconfig that matches a module load request.
Parameter absolutePathMappings
The paths to try as specified in tsconfig but resolved to absolute form.
Parameter requestedModule
The required module name.
Parameter readJson
Function that can read json from a path (useful for testing).
Parameter fileExists
Function that checks for existence of a file at a path (useful for testing).
Parameter extensions
File extensions to probe for (useful for testing).
Parameter mainFields
A list of package.json field names to try when resolving module files. Select a nested field using an array of field names.
Returns
the found path, or undefined if no path was found.
function matchFromAbsolutePathsAsync
matchFromAbsolutePathsAsync: ( absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>, requestedModule: string, readJson: Filesystem.ReadJsonAsync | undefined, fileExists: Filesystem.FileExistsAsync | undefined, extensions: readonly string[] | undefined, callback: MatchPathAsyncCallback, mainFields?: (string | string[])[]) => void;
See the sync version for docs.
function register
register: (params?: RegisterParams) => () => void;
Installs a custom module load function that can adhere to paths in tsconfig. Returns a function to undo paths registration.
Interfaces
interface ConfigLoaderFailResult
interface ConfigLoaderFailResult {}
property message
message: string;
property resultType
resultType: 'failed';
interface ConfigLoaderSuccessResult
interface ConfigLoaderSuccessResult {}
property absoluteBaseUrl
absoluteBaseUrl: string;
property addMatchAll
addMatchAll?: boolean;
property baseUrl
baseUrl?: string;
property configFileAbsolutePath
configFileAbsolutePath: string;
property mainFields
mainFields?: (string | string[])[];
property paths
paths: { [key: string]: Array<string>;};
property resultType
resultType: 'success';
interface FileExistsAsync
interface FileExistsAsync {}
call signature
(path: string, callback: (err?: Error, exists?: boolean) => void): void;
interface FileExistsSync
interface FileExistsSync {}
call signature
(name: string): boolean;
interface MatchPath
interface MatchPath {}
Function that can match a path
call signature
( requestedModule: string, readJson?: Filesystem.ReadJsonSync, fileExists?: (name: string) => boolean, extensions?: ReadonlyArray<string>): string | undefined;
interface MatchPathAsync
interface MatchPathAsync {}
Function that can match a path async
call signature
( requestedModule: string, readJson: Filesystem.ReadJsonAsync | undefined, fileExists: Filesystem.FileExistsAsync | undefined, extensions: ReadonlyArray<string> | undefined, callback: MatchPathAsyncCallback): void;
interface ReadJsonAsync
interface ReadJsonAsync {}
call signature
(path: string, callback: ReadJsonAsyncCallback): void;
interface ReadJsonSync
interface ReadJsonSync {}
A function that json from a file
call signature
(packageJsonPath: string): any | undefined;
Type Aliases
type ConfigLoaderResult
type ConfigLoaderResult = ConfigLoaderSuccessResult | ConfigLoaderFailResult;
Package Files (6)
Dependencies (3)
Dev Dependencies (19)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/tsconfig-paths
.
- Markdown[](https://www.jsdocs.io/package/tsconfig-paths)
- HTML<a href="https://www.jsdocs.io/package/tsconfig-paths"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3887 ms. - Missing or incorrect documentation? Open an issue for this package.