babel-plugin-on-demand-import

1.1.1 • Public • Published

build pass js-standard-style npm-version license

babel-plugin-on-demand-import

Babel plugin for importing components on demand.

Installation

Install the pkg with npm:

npm i babel-plugin-on-demand-import -D

or yarn

yarn add babel-plugin-on-demand-import -D

Usage

Via .babelrc or babel-loader.

{
  "plugins": [["on-demand-import", options]]
}

options

options can be object.

{
    libraryName: 'test',
    libraryPath: 'lib',  // default: lib
    stylePath: 'your-style-path', // defalut: undefined
    needImportStyle: true       // default: false
}

options can be an array.

[
    {
        libraryName: 'test1'
    },
    {
        libraryName: 'test2'
    }
]

Example

{ "libraryName": "test1" }

import { A } from 'test1';

     

var a = require('test1/lib/a');

{ "libraryName": "test2", libraryPath: 'dist/my-library', stylePath: 'style1', needImportStyle: true }

import { B } from 'test2';

↓ ↓ ↓ ↓ ↓ ↓

var b = require('test2/dist/my-library/b');
require('test2/style1/b.css');

LICENSE

MIT

Package Sidebar

Install

npm i babel-plugin-on-demand-import

Weekly Downloads

17

Version

1.1.1

License

MIT

Unpacked Size

6.73 kB

Total Files

4

Last publish

Collaborators

  • dwqs