babel-resolve

0.1.0 • Public • Published

babel-resolve

Create a babel resolve function. This allows you to easily require your project's local modules without passing in relative paths.

Install

npm i --save-dev babel-resolve

Usage

var babelResolve = require('babel-resolve')
var resolver = babelResolve('local/', './src/_local_modules')
require('babel/resolve')({resolve: resolver.resolve})

Now, in your program, you can import like:

import mymodule from 'local/mymodule'

API

create(prefix, dir)

class method that creates a resolver object that has methods resolve() and mapKeys().

resolve()

instance method that returns a function for Babel to resolve your modules.

mapKeys(stubObject)

instance method that takes as input stubObject and returns a clone of it with the keys replaced with resolve(key). Useful for stubbing.

License

MIT

Copyright (c) [JP Richardson][https://github.com/jprichardson]

Package Sidebar

Install

npm i babel-resolve

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • jprichardson