ES6 import from root

Had the same issue with React.
So i wrote some plugin for babel which make it possible to import the modules from the root perspective – the paths are not shorter – but it’s clear what you import.

So instead of:

import 'foo' from '../../../components/foo.js';

You can use:

import 'foo' from '~/components/foo.js';

Here is the Plugin (tested and with a clear README)

Leave a Comment