0.2.4 • Published 5 years ago

babel-plugin-local-import v0.2.4

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

babel-plugin-local-import

NPM version npm download

install

ljshell

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';
0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago