Needs work
Project:
Drupal core
Version:
main
Component:
javascript
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
19 Apr 2015 at 09:30 UTC
Updated:
30 Jan 2023 at 20:37 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
nod_Comment #2
wim leersWe shouldn't do this, but fix #1945262: Replace custom weights with dependencies in library declarations; introduce "before" and "after" for conditional ordering instead. Then you don't need to specify it in JS, but in the asset library metadata. Because then it'll continue to work when the dependency tree. Specifying this in the JS will not automatically be made aware of additional library dependencies/before/after metadata, but specifying it in the asset library metadata will.
Comment #3
nod_Have the before after suff in php based on files then?
I'm fine with it being in PHP. I'm actually a bit worried the whole resolution stuff in the js for before/after is going to require too much code.
Comment #4
wim leersYes.
core/drupaldepends oncore/drupalSettingsanyway. So we can pass the relevant asset library ordering information inwindow.drupalSettings.Comment #10
slydevil commentedAlright, I took a stab at this. Added logic to the AssetResolver class to modify the javascript weights based on 'before' or 'after' dependencies.
I didn't take into account scenarios where there are both 'before' and 'after' dependencies and the weight of those dependencies is opposite of what it needs to be. For example, fileB has a 'before' dependency on fileA and an 'after' dependency of fileC:
fileA = 0.091
fileB = 0.092
fileC = 0.093
The expected order would be:
fileC = 0.091
fileB = 0.092
fileA = 0.093
However, the patch will apply the 'before' and then the 'after' without modifying the weight of the dependencies. So the actual order would be:
fileA = 0.091
fileC = 0.093
fileB = 0.0931
Coding this will be complex and I think this patch is a good start.
Comment #20
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.