Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dwqs/babel-plugin-on-demand-import
Babel plugin for importing components on demand
https://github.com/dwqs/babel-plugin-on-demand-import
babel babel-plugin import on-demand
Last synced: 2 months ago
JSON representation
Babel plugin for importing components on demand
- Host: GitHub
- URL: https://github.com/dwqs/babel-plugin-on-demand-import
- Owner: dwqs
- License: mit
- Created: 2018-03-11T07:36:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-20T14:05:58.000Z (over 6 years ago)
- Last Synced: 2024-10-05T08:07:48.951Z (3 months ago)
- Topics: babel, babel-plugin, import, on-demand
- Language: JavaScript
- Size: 19.5 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![build pass](https://api.travis-ci.org/dwqs/babel-plugin-on-demand-import.svg?branch=master)](https://travis-ci.org/dwqs/babel-plugin-on-demand-import?branch=master) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com) ![npm-version](https://img.shields.io/npm/v/babel-plugin-on-demand-import.svg) ![license](https://img.shields.io/npm/l/babel-plugin-on-demand-import.svg)
# 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" }**
```js
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');
```## Used Components
* [v2-datepicker](https://github.com/dwqs/v2-datepicker/)
* [vue-area-linkage](https://github.com/dwqs/vue-area-linkage)
* [react-area-linkage](https://github.com/dwqs/react-area-linkage)## Similar project
* [babel-plugin-replace-import-path](https://github.com/fmfe/babel-plugin-replace-import-path)## LICENSE
MIT