`AssetResolver::getJsSettingsAssets()` calls `::getLibrariesToLoad()` with wrong asset type

Created on 1 July 2025, 5 days ago

Problem/Motivation

Discovered while working on šŸ“Œ Populate data to drupalSettings to enable Dynamic Code Components Active .

When defining a drupalSettings-only asset library, such as:

mySettings:
  dependencies:
    - core/drupalSettings
  drupalSettings:
    myModule:
      foo: null
      bar: null

which is similar to how core defines its placeholder settings for the asset library definitions to be as declarative as possible:

drupalSettings:
  version: VERSION
  js:
    # Need to specify a negative weight like drupal.js until
    # https://www.drupal.org/node/1945262 is resolved.
    misc/drupalSettingsLoader.js: { weight: -18 }
  drupalSettings:
    # These placeholder values will be set by system_js_settings_alter().
    path:
      baseUrl: null
      pathPrefix: null
      currentPath: null
      currentPathIsAdmin: null
      isFront: null
      currentLanguage: null
    pluralDelimiter: null

… then this doesn't work, because js is not set, and even if it were set to js: {}, it wouldn't work. Because AssetResolver::getJsSettingsAssets()'s

foreach ($this->getLibrariesToLoad($assets, 'js') as $library) {

should be

foreach ($this->getLibrariesToLoad($assets, 'drupalSettings') as $library) {

Steps to reproduce

See above.

Proposed resolution

  1. Explicit test coverage
  2. Fix

Remaining tasks

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

Pure drupalSettings asset libraries are resolved as expected.

šŸ› Bug report
Status

Active

Version

11.2 šŸ”„

Component

asset library system

Created by

šŸ‡§šŸ‡ŖBelgium wim leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

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

Merge Requests

Comments & Activities

  • Issue created by @wim leers
  • šŸ‡³šŸ‡æNew Zealand quietone
  • First commit to issue fork.
  • Merge request !12566Update 2 files → (Open) created by immaculatexavier
  • Pipeline finished with Failed
    5 days ago
    Total: 351s
    #536185
  • Pipeline finished with Failed
    5 days ago
    Total: 153s
    #536200
  • Pipeline finished with Failed
    5 days ago
    Total: 156s
    #536207
  • Pipeline finished with Failed
    5 days ago
    Total: 148s
    #536215
  • Pipeline finished with Failed
    5 days ago
    Total: 168s
    #536216
  • Pipeline finished with Failed
    5 days ago
    #536233
  • Pipeline finished with Failed
    5 days ago
    Total: 237s
    #536281
Production build 0.71.5 2024