1.2.0 • Published 1 year ago

@mnrendra/obtain-tsconfig-paths v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@mnrendra/obtain-tsconfig-paths

Obtain a valid baseUrl and paths from the compilerOptions in the tsconfig.json file so you don't need to import and validate the tsconfig.json file manually.

Install

npm i @mnrendra/obtain-tsconfig-paths

Usage

Using CommonJS:

const { obtainTSConfigPaths, obtainTSConfigPathsSync } = require('@mnrendra/obtain-tsconfig-paths')

// Asynchronously
obtainTSConfigPaths()
  .then(({ baseUrl, paths }) => {
    console.log('asynchronously:', baseUrl, paths)
  })

// Synchronously
const { baseUrl, paths } = obtainTSConfigPathsSync()
console.log('synchronously:', baseUrl, paths)

Using ES Module:

import { obtainTSConfigPaths, obtainTSConfigPathsSync } from '@mnrendra/obtain-tsconfig-paths'

// Asynchronously
obtainTSConfigPaths()
  .then(({ baseUrl, paths }) => {
    console.log('asynchronously:', baseUrl, paths)
  })

// Synchronously
const { baseUrl, paths } = obtainTSConfigPathsSync()
console.log('synchronously:', baseUrl, paths)

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-tsconfig
  TSConfig,
  CompilerOptions,
  BaseURL,
  Paths,
  // @mnrendra/obtain-tsconfig-paths
  TSConfigPaths
} from '@mnrendra/obtain-tsconfig-paths'

License

MIT

Author

@mnrendra

1.2.0

1 year ago

1.2.2

9 months ago

1.2.1

9 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago