Galooshi / import-js

A tool to simplify importing JS modules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for babel-plugin-module-resolver

zeorin opened this issue · comments

https://github.com/tleunen/babel-plugin-module-resolver is a fairly widely used babel plugin, which allows for aliases and root folders. E.g. with the following in .babelrc:

{
  "plugins": [
    ["module-resolver", {
      "root": ["./src"],
      "alias": {
        "test": "./test",
        "underscore": "lodash"
      }
    }]
  ]
}

you can write

import { throttle } from 'underscore';
import { MockBar } from 'test';
import Foo from 'components/Foo';

instead of

import { throttle } from 'lodash';
import { MockBar } from '../../test';
import Foo from '../../src/components/Foo';

It'd be nice if import-js picked up on this and its output was in line with it.