Package Exports
- babel-plugin-require-root-rewrite
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-require-root-rewrite) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
babel-plugin-require-root-rewrite
A Babel plugin for requiring files relative to the project root.
Example
In: /path/to/project/containers/Register/Register.js
const BaseAuthForm = require('~/components/BaseAuthForm');or
import BaseAuthForm from '~/components/BaseAuthForm';Out
var BaseAuthForm = require('../../components/BaseAuthForm');Installation
$ npm install babel-plugin-require-root-rewriteUsage
Via .babelrc (Recommended)
.babelrc
{
"plugins": [
["babel-plugin-require-root-rewrite", {
"pattern": "^~/",
"basePath": "lib",
"overrides": [
"api",
"server"
]
}]
]
}Via CLI
$ babel --plugins babel-plugin-require-root-rewrite script.jsVia Node API
require('babel-core').transform('code', {
plugins: ['babel-plugin-require-root-rewrite']
});