Socket
Book a DemoInstallSign in
Socket

babel-plugin-tsconfig-paths

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-tsconfig-paths

Resolve imports/requires based on paths from tsconfig.json

1.0.3
latest
Source
npmnpm
Version published
Weekly downloads
9.2K
6.01%
Maintainers
1
Weekly downloads
 
Created
Source

Babel plugin for resolving path aliases from tsconfig.json

Install

npm install -D babel-plugin-tsconfig-paths

Configure

// .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:

      [
        "require",
        "require.resolve",
        "System.import",
        "jest.genMockFromModule",
        "jest.mock",
        "jest.unmock",
        "jest.doMock",
        "jest.dontMock",
        "jest.setMock",
        "require.requireActual",
        "require.requireMock"
      ]
      

FAQs

Package last updated on 08 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.