8👍
Turns out the issue is chart.js in npm depends on moment.js, which inludes about 250K of locales. The fix is to ignore these locale files:
var webpack = require("webpack");
module.exports = {
// ...
plugins: [
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /de|fr|hu/)
// new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
]
};
More info here:
- [Chartjs]-Show point values in Radar Chart using chart.js
- [Chartjs]-Charts disappear if rendered in hidden divs
1👍
As JOP explained, Chart.JS depends on moment.js package that has 250K with locales.
If you don’t have dates in your chart data you can remove moment package completely from result bundle without replacing it with another package. Moment package just could be marked as an external dependency in webpack.
I.e. something like this, depending on you webpack configuration.
module.exports = {
...
externals: {
moment: 'moment',
},
}
Source:stackexchange.com