babel-plugin-transform-import-resolve
v2.0.1
Published
Resolve import paths for named dependencies
Downloads
7
Maintainers
Readme
babel-plugin-transform-import-resolve
Resolve import paths for named dependencies
Example
In
import derp from 'derp'
Out
import derp from './node_modules/derp/lib/index.js'
Installation
$ npm install babel-plugin-transform-import-resolve
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["transform-import-resolve"]
}
Via CLI
$ babel --plugins transform-import-resolve script.js
Via Node API
require('babel-core').transform('code', {
plugins: ['transform-import-resolve']
})
To override how the path is transformed, pass a Function to the parse
option:
const options = {
function parse (basedir, dependency, source, filename) {
return path.relative(basedir, dependency)
}
}
require('babel-core').transform('code', {
plugins: ['transform-import-resolve', options]
})