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;
// }
//.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