🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

babel-plugin-relative-import

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-relative-import

Babel Plugin to enable relative imports

1.0.3
latest
Source
npm
Version published
Weekly downloads
157
53.92%
Maintainers
1
Weekly downloads
 
Created
Source

Babel Plugin Relative Import

Build Status Dependency Status devDependency Status https://github.com/mgcrea/babel-plugin-relative-import

Import relative files with ease

import fooHelper from '~/helpers/example.js';
// Gets compiled to:
import fooHelper from './../../../helpers/foo.js';
// No more relative path mess!

Quickstart

npm install babel-plugin-relative-import --save-dev

Add a .babelrc file and write:

{
  "plugins": [
    "babel-plugin-relative-import"
  ]
}

Options

You can use a custom root with the rootPathSuffix option.

{
  "plugins": [
    ["babel-plugin-relative-import", {
      "rootPathSuffix": "src/js"
    }]
  ]
}

You can also use a path starting with %/ in your rootPathSuffix to automatically resolve the closest package.json.

Inspiration

Inspired by the babel-root-import from Michael J. Zoidl.

FAQs

Package last updated on 11 May 2016

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