Socket
Socket
Sign inDemoInstall

babel-resolve

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-resolve

Create a resolve function for babel/register.


Version published
Weekly downloads
1
Maintainers
1
Install size
14.5 kB
Created
Weekly downloads
 

Readme

Source

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]

Keywords

FAQs

Last updated on 26 Jul 2015

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc