Drupal uses *.libraries.yml
files to declare asset libraries (containing CSS and JS files) that are provided by themes and modules. Sometimes there is a need to stop providing an asset library. This may be due to an external asset library which has reached EOL, or an asset library which for whatever reason is no longer useful in Drupal core. Removing these asset libraries is a BC break and can only be done in a major version release of Drupal core. Previously there has been no way to mark an asset library as deprecated to schedule its removal.
Drupal's *.libraries.yml
may now add a deprecated
key to an asset library to indicate that the asset library is deprecated and will be removed in the next major version. This key should contain the deprecation information in the standard format, and may use the token %library_id%
as a placeholder for the library name. The LibraryDiscovery
service will then trigger an error if this library is accessed.
- Before
-
There was no way to trigger a deprecation error.
jquery.ui.effects.scale: version: *jquery_ui_version license: *jquery_ui_license js: assets/vendor/jquery.ui/ui/effects/effect-scale-min.js: { minified: true } dependencies: - core/jquery.ui.effects.core
- After
- An asset library can be marked as deprecated and an error will be triggered.
jquery.ui.effects.scale: version: *jquery_ui_version license: *jquery_ui_license js: assets/vendor/jquery.ui/ui/effects/effect-scale-min.js: { minified: true } dependencies: - core/jquery.ui.effects.core deprecated: The "%library_id%" asset library is deprecated in drupal:8.8.0 and will be removed in drupal:9.0.0. Require jQuery UI as an explicit dependency or create a pure JavaScript solution. See https://www.drupal.org/node/3064015