Deprecate support for per-file weight in libraries API

Created on 11 August 2024, 5 months ago

Problem/Motivation

📌 Replace custom weights with dependencies in library declarations; introduce "before" and "after" for conditional ordering Needs work fixes core libraries so that they no longer depend on individual file weights, but instead on declaring correct dependencies between each other.

The next step is to deprecate weight support in the assets API.

For JavaScript we should be able to just issue a deprecation message and then remove support.

For CSS, 'weight' and 'group' are conflated, see:

LibraryDiscoveryParser.php

foreach ($library[$type] as $category => $files) {
            $category_weight = 'CSS_' . strtoupper($category);
            assert(defined($category_weight), 'Invalid CSS category: ' .        $category . '. See https://www.drupal.org/node/2274843.');
            foreach ($files as $source => $options) {
              if (!isset($options['weight'])) {
                $options['weight'] = 0;
              }
              // Apply the corresponding weight defined by CSS_* constants.
              $options['weight'] += constant($category_weight);
              $library[$type][$source] = $options;

So that is going to need a bit more thought.

There is also 📌 Remove separate CSS_AGGREGATE_THEME aggregate file Needs work to consider.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component
Asset library 

Last updated 5 days ago

No maintainer
Created by

🇬🇧United Kingdom catch

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

Comments & Activities

Production build 0.71.5 2024