Problem/Motivation

When too many javascript files, weight calculation can be messy.

Ckeditor 5 (experimental for now) adds a lot (like hundreds) of javascripts translation files.

On its side Assets resolver modify the js weight from the total count of javascript files :

On web/core/lib/Drupal/Core/Asset/AssetResolver.php:265

// Always add a tiny value to the weight, to conserve the insertion
// order.
$options['weight'] += count($javascript) / 1000;

When count(javascript) is > 500, then the result is not tiny anymore and can introduce dependencies inclusion order problems.

Steps to reproduce

I created a paragraph with an autocomplete field and placed it above a text field with ckeditor5.
Many errors block javascript (like "Uncaught TypeError: ***** is not a function")

Proposed resolution

Divide with 10000 or greater instead of 1000.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3272295

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

nollim created an issue. See original summary.

nollim’s picture

Issue summary: View changes
nollim’s picture

Issue summary: View changes

nollim’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

Title: Javascript errors in admin when using autocomplete and ckeditor5 » JavaScript errors in admin when using autocomplete and CKEditor 5
Category: Task » Bug report
Issue tags: +Needs tests

Wow, what a find! 🤯

I think we'll want a test for this.

wim leers’s picture

Woah, thanks, @nod_!

Duplicate indeed. 👍 Let's continue there, since it already has test coverage.