How to remove unused core modules from Magento 2?

To reduce the load time sometimes we should to disable core modules for performance or security reasons. There, I sharing here the default way to disable a module:

bin/magento module:disable Vendor_Module

But in the above method below problem will be arise:

  • Module will be disable but files are still there.
  • If you run integration tests or static tests, it will run with including the disabled modules.
    So, we need a method to remove the module in a right way with the help of composer

Remove module with composer

As the core modules are loaded via composer as dependencies, we cannot simply remove them from the composer.json. we can remove those via replace capability.

composer file looks like below with replace key

“require”: {
[…]
},
“replace”: {
     “magento/module-marketplace”: “*”
},
“config”: {
[…]

Example to remove core modules like dotmailer, vertex, yotpo  below

“replace”:{
      “dotmailer/dotmailer-magento2-extension”: “*”,
      “dotmailer/dotmailer-magento2-extension-package”: “*”,
      “dotmailer/dotmailer-magento2-extension-enterprise”: “*”,
      “dotmailer/dotmailer-magento2-extension-chat”: “*”,
      “vertex/module-tax”: “*”,
      “vertex/sdk”: “*”,
      “vertex/module-address-validation”:”*”,
      “yotpo/magento2-module-yotpo-reviews” : “*”
},

Then, run the “composer update” command to remove the core modules which is mentioned inside replace section.

Scroll to Top