diff --git a/src/StarterKits/InstallableModules.php b/src/StarterKits/InstallableModules.php index ef56cb5ae7..d38e1ef5be 100644 --- a/src/StarterKits/InstallableModules.php +++ b/src/StarterKits/InstallableModules.php @@ -77,7 +77,7 @@ protected function instantiateModuleRecursively(Collection|array|string $config, { if ($imported = $config === '@import') { $config = $this->importModuleConfig($key); - } elseif ($imported = Arr::get($config, 'import') === '@config') { + } elseif ($imported = $this->moduleConfigExists($key)) { $config = $this->importModuleConfig($key)->merge($config); } @@ -170,6 +170,16 @@ protected function relativeModulePath(string $key, ?string $path = null): string : $base; } + /** + * Determine whether module config exists. + */ + protected function moduleConfigExists(string $key): bool + { + return $this->files->exists( + $this->starterKitPath($this->relativeModulePath($key, 'module.yaml')) + ); + } + /** * Scope installable files to imported module. */ diff --git a/tests/StarterKits/InstallTest.php b/tests/StarterKits/InstallTest.php index 834da8322d..cc732b5c14 100644 --- a/tests/StarterKits/InstallTest.php +++ b/tests/StarterKits/InstallTest.php @@ -1120,14 +1120,14 @@ public function it_can_merge_imported_module_config_with_starter_kit_config() 'modules' => [ 'seo' => [ 'prompt' => 'Want some extra SEO magic?', // handle prompt flow here - 'import' => '@config', // but import and merge rest of config + // implicitly import and merge rest of config in here ], 'js' => [ 'prompt' => 'Want one of these fancy JS options?', 'options' => [ 'react' => [ 'label' => 'React JS', // handle prompt option label here - 'import' => '@config', // but import and merge rest of config + // implicitly import and merge rest of config in here ], 'svelte' => [ 'export_paths' => [ @@ -1154,7 +1154,7 @@ public function it_can_merge_imported_module_config_with_starter_kit_config() config: [ 'label' => 'This should not get used, because prompt config in starter-kit.yaml takes precedence!', 'export_paths' => [ - $this->moveKitRepoFile('modules/js/react', 'resources/js/react.js'), + $this->moveKitRepoFile('modules/js/react', 'resources/js/react.js'), // but this should still be imported and installed ], ], );