@mnrendra/tsconfig-alias-parser
v1.3.0
Published
Parse the baseUrl and paths from tsconfig.json into aliases.
Downloads
122
Maintainers
Readme
@mnrendra/tsconfig-alias-parser
Parse the baseUrl
and paths
from tsconfig.json
into aliases. This will automatically read baseUrl
and paths
from tsconfig.json
and convert them into aliases that can be used by @mnrendra/alias-resolver to resolve all alias paths.
Install
npm i @mnrendra/tsconfig-alias-parser
Usage
Using CommonJS
:
const { parseTSConfigAlias, parseTSConfigAliasSync } = require('@mnrendra/tsconfig-alias-parser')
// Asynchronously
parseTSConfigAlias()
.then((aliases) => {
console.log('asynchronously:', aliases)
})
// Synchronously
const aliases = parseTSConfigAliasSync()
console.log('synchronously:', aliases)
Using ES Module
:
import { parseTSConfigAlias, parseTSConfigAliasSync } from '@mnrendra/tsconfig-alias-parser'
// Asynchronously
parseTSConfigAlias()
.then((aliases) => {
console.log('asynchronously:', aliases)
})
// Synchronously
const aliases = parseTSConfigAliasSync()
console.log('synchronously:', aliases)
Options
• baseUrl
type: BaseURL|null|undefined
default: undefined
tsconfig.json
's compilerOptons.baseUrl
.
• paths
type: Paths|null|undefined
default: undefined
tsconfig.json
's compilerOptons.paths
.
Types
import type {
// @mnrendra/types-aliases
Aliases,
Alias,
// @mnrendra/types-tsconfig
TSConfig,
CompilerOptions,
BaseURL,
Paths
} from '@mnrendra/tsconfig-alias-parser'