matthewp / babel-plugin-modules-map

Map module specifiers to other names

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-plugin-modules-map

Map configuration for modules, as a Babel plugin. Rewrites module specifiers to apply aliases.

For example, this code:

import mod from 'foo';

Will be transformed into:

import mod from 'bar';

When using the config: {foo: 'bar'}.

Install

yarn add babel-plugin-modules-map --dev

Usage

In your .babelrc add:

{
  "plugins": [
    ["modules-web-compat", {
      "foo": "bar"
    }]
  ]
}

The second argument being your map configuration. A map is like an alias from one name to another. Partial matches are also applied so that:

import mod from 'foo/baz';

With the config:

{
  "plugins": [
    ["modules-web-compat", {
      "foo": "bar"
    }]
  ]
}

Will become:

import mod from 'bar/baz';

License

BSD 2 Clause

About

Map module specifiers to other names


Languages

Language:JavaScript 100.0%