A babel plugin help you import less Recharts modules.
$ npm i -D babel-plugin-recharts
The plugin automatically compiles this :
import { XAxis, YAxis, CartesianGrid, Area, AreaChart, Tooltip,
ResponsiveContainer } from 'recharts';
into this:
'use strict';
require('recharts/lib/polyfill.js');
require('core-js/es6/math');
var _Line = require('recharts/lib/cartesian/Line.js');
var _Line2 = _interopRequireDefault(_Line);
var _Area = require('recharts/lib/cartesian/Area.js');
var _Area2 = _interopRequireDefault(_Area);
var _Treemap = require('recharts/lib/chart/Treemap.js');
var _Treemap2 = _interopRequireDefault(_Treemap);
var _Pie = require('recharts/lib/polar/Pie.js');
var _Pie2 = _interopRequireDefault(_Pie);
var _Cell = require('recharts/lib/component/Cell.js');
var _Cell2 = _interopRequireDefault(_Cell);
var _recharts = require('recharts');
var _recharts2 = _interopRequireDefault(_recharts);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Hence you end up loading less modules.
{
"plugins": ["recharts"],
"presets": ["es2015"]
}
'module': {
'loaders': [{
'loader': 'babel-loader',
'test': /\.js$/,
'exclude': /node_modules/,
'query': {
'plugins': ['recharts'],
'presets': ['es2015']
}
}]
}
- You must use ES2015 imports to load recharts
Copyright (c) 2015-2016 Recharts Group