Search code examples
vue.jsxlsxpdfmake

Removing unused heavy packages from vue.js


So recently I have been really wanting to speed up my website that is kinda heavy but when I built the app I noticed that I have 2 packages that are really heavy and I'm not using or at least I don't know whats using them.

The packages are pdmake.js and xlsx.js as you can see in the picture below: enter image description here

I tried to uninstall them but it didn't work I also checked package.json and they aren't there so I'm really confused about these 2 specific packages. I also don't have any of these files in my js folder or any folder in my project.


Solution

  • pdfmake.js and xlsx.js are included by AmCharts

    They are fetched by browsers dynamically and only when needed - so the only downside is increased build time. If you are sure you do not need/use these - you can disable them through vue.config.js:

    // vue.config.js
    module.exports = {
      chainWebpack: config => 
      {
        config.externals = function (context, request, callback) 
        {
          if (/xlsx|canvg|pdfmake/.test(request)) 
          {
            return callback(null, "commonjs " + request);
          }
          callback();
        }
      }
    }