diff --git a/Generator/Module.php b/Generator/Module.php
index <HASH>..<HASH> 100644
--- a/Generator/Module.php
+++ b/Generator/Module.php
@@ -338,9 +338,6 @@ class Module extends RootComponent {
     // Modules always have a .info file.
     $components['info'] = 'Info';
 
-    // TODO: this should only be on D7 and lower.
-    $components['%module.module'] = 'ModuleCodeFile';
-
     return $components;
   }
 
diff --git a/Generator/Module7.php b/Generator/Module7.php
index <HASH>..<HASH> 100644
--- a/Generator/Module7.php
+++ b/Generator/Module7.php
@@ -24,4 +24,16 @@ class Module7 extends Module {
     return $component_data_definition;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  protected function requiredComponents() {
+    $components = parent::requiredComponents();
+
+    // On D7 and lower, modules need a .module file, even if empty.
+    $components['%module.module'] = 'ModuleCodeFile';
+
+    return $components;
+  }
+
 }
Fixed empty .module being generated on D8.