easy-import
v0.3.0
Published
Babel plugin. An easy way to include modules in your JavaScript code.
Downloads
18
Maintainers
Readme
Easy Import
A package-like importer for JavaScript and Babel.
Installation
npm install --save-dev easy-import
"plugins": ["easy-import"]
-.babelrc
options
Options
from
- folder you are building your files fromto
- folder you are building your files toignore
- defaultnode_modules
- ignore directories in root
"plugins": [["easy-import", {
"from": "src",
"to": "dist",
"ignore": ["node_modules", "coverage"]
}]]
Example
./src/packages/math.js
// @package Math
const main = Math;
const multiply = (a, b, c) => a * b * c;
const sum = (a, b, c) => a + b + c;
export default main;
export {
multiply,
sum,
};
./src/controllers/anything.js
import math, { multiply, sum } from 'Math';
// or import * as math from 'Math'
// or import { multiply } from 'Math'
console.log(multiply(1, 2, 3), sum(1, 2, 3), math.min(100, 200));