function removeFromModules({ logger, moduleName, packageName, modulePackageName, old }) {
  // Gets modules entry point file path
  const modulesEntry = getModulesEntryPoint(packageName, old);

  let indexContent;

  try {
    indexContent = fs.readFileSync(modulesEntry);
  } catch (e) {
    logger.error(chalk.red(`Failed to read ${modulesEntry} file`));
    process.exit();
  }

  // Extract application modules
  const appModuleRegExp = /Module\(([^()]+)\)/g;
  const [, appModules] = appModuleRegExp.exec(indexContent) || ['', ''];
  const appModulesWithoutDeleted = appModules.split(',').filter((appModule) => appModule.trim() !== moduleName);

  const contentWithoutDeletedModule = indexContent
    .toString()
    // Remove module from modules list
    .replace(appModuleRegExp, `Module(${appModulesWithoutDeleted.toString().trim()})`)
    // Remove module import
    .replace(
      RegExp(`import ${moduleName} from '${computeModulePackageName(moduleName, modulePackageName, old)}';\n`, 'g'),
      ''
    );

  fs.writeFileSync(modulesEntry, contentWithoutDeletedModule);
  runPrettier(modulesEntry);
}
Removes module from modules entry file.