babel-plugin-quick-quote

1.0.7 • Public • Published

Babel Plugin Quick Quote

NPM Version NPM Downloads Build Status

babel plugin quickly introduce the echarts module on demand

import {$_quickQuote} from 'babel-plugin-quick-quote/lib/tool'
const echarts = $_quickQuote([
  'line',
  'bar'
]), test = 'test';
// transform:
// import echarts from "echarts/lib/echarts";
// import "echarts/lib/chart/line";
// import "echarts/lib/chart/bar";
// const test = 'test';
// If there is no corresponding configuration in the configuration file quick-quote.config.js,
// output will be as it is.
import {$_quickQuote} from 'babel-plugin-quick-quote/lib/tool'
const echarts = $_quickQuote([
  'path/demo/path',
  'line',
  'bar'
])
 
// transform:
// import echarts from "echarts/lib/echarts";
// import "path/demo/path";
// import "echarts/lib/chart/line";
// import "echarts/lib/chart/bar";
import {$_quickQuote} from 'babel-plugin-quick-quote/lib/tool'
$_quickQuote([
  'line',
  'bar'
])
 
// transform:
// import "echarts/lib/echarts";
// import "echarts/lib/chart/line";
// import "echarts/lib/chart/bar";
import {$_quickQuoteAsync} from 'babel-plugin-quick-quote/lib/tool'
const initEcharts = $_quickQuoteAsync([
  'line',
  'bar'
])
// transform:
// let $_QuickQuote_echartsInstance = null;
// function initEcharts() {
//   if (!$_QuickQuote_echartsInstance) {
//     $_QuickQuote_echartsInstance =
//       import( /* webpackChunkName: \\"echarts\\" */ 'echarts/lib/echarts').
//         then(echarts => {
//         return Promise.all([echarts,
//         import( /* webpackChunkName: \\"echarts\\" */ 'echarts/lib/chart/line'),
//         import(/* webpackChunkName: \\"echarts\\" */'echarts/lib/chart/bar')]).
//         then(([echarts]) => echarts);
//     });
//   }
//   return $_QuickQuote_echartsInstance;
// }
//If there is no variable name, it will default to
// function getEchartsInstance()
import {$_quickQuoteAsync} from 'babel-plugin-quick-quote/lib/tool'
$_quickQuoteAsync([
  'line',
  'bar'
])
// transform:
// let $_QuickQuote_echartsInstance = null;
// function getEchartsInstance() {
//   if (!$_QuickQuote_echartsInstance) {
//     $_QuickQuote_echartsInstance =
//       import( /* webpackChunkName: \\"echarts\\" */ 'echarts/lib/echarts').
//         then(echarts => {
//         return Promise.all([echarts,
//         import( /* webpackChunkName: \\"echarts\\" */ 'echarts/lib/chart/line'),
//         import(/* webpackChunkName: \\"echarts\\" */'echarts/lib/chart/bar')]).
//         then(([echarts]) => echarts);
//     });
//   }
//   return $_QuickQuote_echartsInstance;
// }

Usage

//.babelrc
{
  "plugins": [
    // 'babal-plugin-quick-quote'
    "quick-quote"
  ]
}
//babel.config.js
module.exports = {
  plugins: [
    // 'babal-plugin-quick-quote'
    'quick-quote'
  ]
}

use the babel-plugin-quick-quote command, generate the corresponding configuration file(quick-quote.config.js) for the echarts version currently used by the project.

babal-plugin-quick-quote

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-quick-quote

Weekly Downloads

0

Version

1.0.7

License

MIT

Unpacked Size

19.1 kB

Total Files

16

Last publish

Collaborators

  • dl_run