Problem

DrupalLibraryElementGenerator::generate() turns a render array's attached libraries into elements. It resolves the dependencies itself but atm ignores weight. Next, it ships drupal-settings of the render-tree, but does not add settings provided via hook_js_settings_build().

This leads to issues when e.g. drupal/ajax library shall be loaded but its settings are missing.

Steps to reproduce

1. Any custom-elements route whose render array attaches core/drupal.dialog.ajax (a form with an AJAX dialog is enough).
2. Render the payload's drupal-library-* elements with the frontend loader (nuxtjs-drupal-ce loadLibrary() / lupus-nuxt3-kickstart's drupal-library--default.vue).
3. Console: the errors above; Drupal.ajax(...) throws on drupalSettings.ajaxTrustedUrl.

Proposed resolution

Run the AssetResolver::getJsAssets() pipeline on the resulting libraries.

Note: I created the issue with help of AI.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fago created an issue. See original summary.

fago’s picture

Priority: Minor » Normal
Status: Active » Needs review

MR attached! Note: I created the MR with help of AI.

fago’s picture

fago’s picture

Status: Needs review » Needs work

I ran regression tests on this and found one difference. drupal-library-locale-translations vanishes on webform routes.

Explained by the AI agent like this:

1. Libraries with no declared files — locale/translations has js: {}; the patch emits an element only where files were grouped (if (empty($js[$name])) continue;), so drupal-library-locale-translations vanishes. The old walk emitted the element (empty).

Proposed fix emit an element for every resolved library even without files.