Determine and implement JS dependency approach

Created on 9 June 2025, 25 days ago

Problem/Motivation

Several of admin_toolbars JS files/behaviors depend on core libraries (e.g. core/drupal, core/jquery, core/once) but do not explicitly declare those dependencies in admin_toolbar.libraries.yml.

This hasn't proven an issue in the past, as they all declare a dependency on admin_toolbar/toolbar.tree, which, in turn depends on toolbar/toolbar (core's Toolbar module), which has ensured that all the necessary libraries were available.

An evaluation of core's approach to dependencies indicates this may not be best practice (what happens if the lib you were depending one to load all those dependencies drops one or more of them?). That suggests that admin_toolbar should explicitly declare any dependencies for each file/behavior.

Proposed resolution

Decide on whether or not to declare all dependencies, evaluate each JS file and make the appropriate changes to admin_toolbar.libraries.yml.

-OR-

Stick with the current approach and close this issue.

Remaining tasks

  • Decide approach
  • Open MR
  • Review and test
  • Merge

User interface changes

None

API changes

None

Data model changes

None

πŸ“Œ Task
Status

Active

Version

3.6

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @justcaldwell
  • πŸ‡ΊπŸ‡ΈUnited States erutan

    Explicitly adding dependencies makes it less likely the module will break in the future, at the cost of having to explicitly declare them once. Unless a dependency name changes while it's functions don't or something kind of bizarre like that there doesn't seem to be much of a downside unless I'm missing something obvious.

    It's also a bit self-documenting which is nice.

Production build 0.71.5 2024