Change record status: 
Project: 
Introduced in branch: 
8.9.x
Introduced in version: 
8.9.0
Description: 

With #474684: Allow themes to declare dependencies on modules themes can now specify dependencies on modules, which means more fundamentally that they can safely use functionality provided by modules. For example a theme could depend on the jquery_update module.

To declare a dependency in your theme you need to add it to the .info.yml file:

name: test theme depending on nonexisting module
type: theme
core_version_requirement: ^8 || ^9
dependencies:
  - my_custom_module:my_custom_module
  - drupal:test_module_non_existing

You should also add the module as a dependency in composer.json, so that it is correctly installed via composer when the theme is installed: https://www.drupal.org/docs/8/creating-custom-modules/add-a-composerjson...

Existing themes that add a new module dependency will fail to update correctly on existing sites unless they install the module first, so when relying on this feature in an existing contributed theme, please communicate clearly to users that there is a new dependency - via the release notes, incrementing the major version number, or similar measures.

Any admin themes that customise the system-themes-page.html.twig template need to update their template overrides for changed markup.

Impacts: 
Site builders, administrators, editors
Module developers
Themers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done

Comments

vaibhavjain’s picture

I tested it and I believe, the dependencies will not enable the module. I checked into the code and it does not enable the module. This does not work the same way as for a module.
Reason - unknown.

Vaibhav Jain

epieddy’s picture

thtas’s picture

I believe the correct format as of 9.4 is as follows:

name: test theme depending on nonexisting module
type: theme
core_version_requirement: ^8 || ^9
dependencies:
  - my_custom_module:my_custom_module
  - drupal:test_module_non_existing
danflanagan8’s picture

I'm convinced you're right, @thtas. You pasted yml from a test theme in the system module, so that has to be the right syntax.

I have updated the change record.