babel-resolver
Advanced tools
Comparing version 0.0.11 to 0.0.12
{ | ||
"name": "babel-resolver", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "Resolve modules from any directory.", | ||
@@ -5,0 +5,0 @@ "main": "lib/createBabelResolver.js", |
@@ -18,7 +18,7 @@ # Babel Resolver [![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url] [![Coverage status][coveralls-image]][coveralls-url] | ||
In app/index.js: | ||
```javascript | ||
var path = require('path'); | ||
var localModulesDir = path.resolve(__dirname, 'app'); | ||
var anotherDirToCheck = path.resolve(__dirname, 'app/lib'); | ||
var resolver = require('babel-resolver')(localModulesDir, anotherDirToCheck); | ||
var localModulesDir = __dirname; | ||
var resolver = require('babel-resolver')(localModulesDir); | ||
@@ -29,4 +29,13 @@ require('babel-core/register')({ | ||
}); | ||
require('./app'); | ||
require('./app.js'); | ||
``` | ||
In app/app.js: | ||
```javascript | ||
import User from 'models/User'; | ||
// => resolves: "app/models/User.js" | ||
``` | ||
**Note:** Run `rm -rf ~/.babel.json` if you're seeing errors. | ||
@@ -38,2 +47,29 @@ | ||
## Resolving Multiple Directories | ||
In app/index.js: | ||
```javascript | ||
var path = require('path'); | ||
var localModulesDir = __dirname; | ||
var anotherDirToCheck = path.resolve(__dirname, 'lib'); | ||
var resolver = require('babel-resolver')(localModulesDir, anotherDirToCheck); | ||
require('babel-core/register')({ | ||
presets: ['es2015'], | ||
resolveModuleSource: resolver | ||
}); | ||
require('./app'); | ||
``` | ||
In app/app.js: | ||
```javascript | ||
import User from 'models/User'; | ||
// => resolves: "app/models/User.js" | ||
import somethingInLib from 'somethingInLib'; | ||
// => resolves: "app/lib/somethingInLib.js" | ||
``` | ||
## Installation | ||
@@ -40,0 +76,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13011
95