Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Js-Brecht/babel-plugin-tsconfig-paths
Resolve imports/requires based on path aliases in tsconfig.json
https://github.com/Js-Brecht/babel-plugin-tsconfig-paths
Last synced: 5 days ago
JSON representation
Resolve imports/requires based on path aliases in tsconfig.json
- Host: GitHub
- URL: https://github.com/Js-Brecht/babel-plugin-tsconfig-paths
- Owner: Js-Brecht
- License: isc
- Created: 2020-07-23T03:52:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-05T06:56:56.000Z (5 months ago)
- Last Synced: 2024-10-31T17:14:59.462Z (12 days ago)
- Language: JavaScript
- Size: 289 KB
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Babel plugin for resolving path aliases from `tsconfig.json`
### Install
```sh
npm install -D babel-plugin-tsconfig-paths
```### Configure
```json
// .babelrc
{
"plugins": [
[
"babel-plugin-tsconfig-paths",
{
"relative": true,
"extensions": [
".js",
".jsx",
".ts",
".tsx",
".es",
".es6",
".mjs"
],
"rootDir": ".",
"tsconfig": "tsconfig.json",
"transformFunctions": [
"require",
"require.resolve",
"System.import",
"jest.genMockFromModule",
"jest.mock",
"jest.unmock",
"jest.doMock",
"jest.dontMock",
"jest.setMock",
"require.requireActual",
"require.requireMock"
]
}
]
]
}
```* `relative` : Generate relative paths instead of absolute paths when
converting aliased import paths.
* Default: `true`* `extensions` : Which file extensions to resolve.
* Default: `[".js", ".jsx", ".ts", ".tsx", ".es", ".es6", ".mjs"]`* `rootDir` : Where to look for `tsconfig.json`.
* Default: `process.cwd()`* `tsconfig`: Relative/absolute location of `tsconfig.json`
* Default: `./tsconfig.json`* `transformFunctions` : Which functions to transform aliases in
* Default:```json
[
"require",
"require.resolve",
"System.import",
"jest.genMockFromModule",
"jest.mock",
"jest.unmock",
"jest.doMock",
"jest.dontMock",
"jest.setMock",
"require.requireActual",
"require.requireMock"
]
```