0.2.4 • Published 5 years ago
babel-plugin-local-import v0.2.4
babel-plugin-local-import
install
Feature
A simple babel plugin for importing local module as in node_modules, and don't need to write tediously long relative path while importing.
Keywords
- babel plugin
- import module
- local module
- relative path
- import module on demand
Usage
configure local module path in .babelrc, for example, a local module in './local/path/moduleA'
{
"plugins": [
["local-import", {
"libraryName": "moduleA",
"libraryDirectory": "./local/path"
}],
["local-import", {
"libraryName": "moduleB",
"libraryDirectory": "./local/path",
"subdirectory": "src/components",
"camel2dash": true,
"expand": true,
}],
]
}
and now, we can import component from 'moduleA' just as it's installed node_modules directory:
import test from 'moduleA';
which will be compiled as:
import test from './local/path/moduleA';
if you want import component from 'moduleB' on demand:
import { TestFunc, TestParam } from 'moduleB';
which will be compiled as:
import TestFunc from './local/path/moduleB/src/components/test-func';
import TestParam from './local/path/moduleB/src/components/test-param';