babel-plugin-module-paths-resolver
TypeScript icon, indicating that this package has built-in type declarations

0.0.105 • Public • Published

babel-plugin-module-paths-resolver

A plugin to resolve tsconfig paths for babel!

Install

$ yarn add babel-plugin-module-paths-resolver

Usage

Specify the plugin in your .babelrc with the custom alias and calls witch will be transform.

{
  "plugins": [
    ["module-paths-resolver", {
      "calls": [
          "jest.genMockFromModule",
          "jest.mock",
          "jest.unmock",
          "jest.doMock",
          "jest.dontMock",
          "jest.setMock",
          "jest.requireActual",
          "jest.requireMock",
      ],
      "alias": {
        "vue": "vue/dist/vue.production.js",
        "react$": "react/dist",
        "react": "react/dev"
      }
    }]
  ]
}

Also the plugin will autoload the config in you tsconfig.json or jsconfig.json.

  • The * key will be ignored!
  • The @components/* will replaced by ./components/*!
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "*": ["./utils/*"],
      "@/*": ["./src/*"],
      "@components/*": ["./components/*", "./src/components/*"]
    }
  }
}

Package Sidebar

Install

npm i babel-plugin-module-paths-resolver

Weekly Downloads

0

Version

0.0.105

License

MIT

Unpacked Size

16.2 kB

Total Files

10

Last publish

Collaborators

  • edonet