score: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',
  },
}

score: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:

how to prevent moment.js from loading locales with webpack?


Related Query

More Query from same tag