A babel plugin for aliasing local module import
npm install babel-plugin-local-importjson
{
"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:
`js
import test from 'moduleA';
`
which will be compiled as:
`js
import test from './local/path/moduleA';
`
---
if you want import component from 'moduleB' on demand:
`js
import { TestFunc, TestParam } from 'moduleB';
`
which will be compiled as:
`js
import TestFunc from './local/path/moduleB/src/components/test-func';
import TestParam from './local/path/moduleB/src/components/test-param';
``