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
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
Comment #2
nollim commentedComment #3
nollim commentedComment #5
nollim commentedComment #7
wim leersWow, what a find! 🤯
I think we'll want a test for this.
Comment #8
nod_It seems like a duplicate of #3222107: Library order asset weights do not work properly when a large number of javascript files is loaded between two jQuery UI libraries
Comment #9
wim leersWoah, thanks, @nod_!
Duplicate indeed. 👍 Let's continue there, since it already has test coverage.