Problem/Motivation

Underscore.js was added to core as a dependency of Backbone.js. Outside of Backbone related code, our usage has been very light. It could take a while to remove all Backbone related code from core on #3145958: [META] Re-evaluate use of Backbone.js in core, so in the mean while we could remove our dependency on Underscore.js.

Proposed resolution

  1. #3270395: Remove use of underscore from editor.admin.js and filter.filter_html.admin.js
  2. Ensure QuickEdit is moving Image integration library there, instead of having it in Image, in #3265140: Move QuickEditImageController from image to quickedit.
  3. Have a child issue to deprecate the library, which will be postponed on #3228986: [Meta] Tasks to deprecate Quick Edit.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#6 3239796-6.patch3.77 KBmurilohp

Comments

lauriii created an issue. See original summary.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

xjm’s picture

Title: Remove dependency on Underscore.js » Remove dependency on Underscore.js outside of Backbone
Priority: Normal » Major
Issue tags: +Drupal 10

Retitling for clarity.

xjm’s picture

Title: Remove dependency on Underscore.js outside of Backbone » Remove dependency on Underscore.js outside of Backbone and mark it internal

 

murilohp’s picture

Assigned: Unassigned » murilohp

I can help you with this one!

murilohp’s picture

Assigned: murilohp » Unassigned
Status: Active » Needs work
StatusFileSize
new3.77 KB

So sorry about my delay here, this is my first time deprecating a JS lib, I made this new patch for D9.4, deprecating it from the core.libraries, do we need deprecation tests here?

Regarding the proposed solution:

  1. Deprecate Underscore.js library, The patch adds a new deprecation message for this.
  2. Load Underscore.js directly on libraries that currently depend on it, I don't think I got this right, the patch adds a new underscore lib on each module that depends on it and points to the file directly on core, I didn't know if it was supposed to be this way.
  3. Open follow-up issues to remove all usages of Underscore.js, We have 4 modules using underscore, editor, filter, image and quickedit

Since we still need to open the follow-ups issues and review the patch. I'll leave this as NW.

mradcliffe’s picture

Just a note that quickedit is going to be removed in 10.0.0 in #3227033: Remove Quick Edit from core. The follow-up for that should be posted in the contrib module, I think.

Can we even pass tests if core itself is using a deprecated asset library? If not, we'd need to do the removal in one issue or block the deprecation on the child issues?

xjm’s picture

Usually we have to do the issues to remove the usage first, and then do the final issue to remove the deprecation. We could convert this issue to a meta issue to do that?

QuickEdit will remain in Drupal 9 core until 2024, so many issues would need to be fixed in both core and contrib QuickEdit until then. In the case of this, though, we could maybe skip/silence the deprecation within QuickEdit since it's essentially end-of-life. Worth exploring, anyway.

murilohp’s picture

We could convert this issue to a meta issue to do that?

Sure! IMHO it's the best idea here, then we could open the follow up issues for the modules: editor, filter, image and quickedit

xjm’s picture

I thought about this more.

QuickEdit will need to retain its dependency on underscore regardless, because it depends on Backbone. So that's not worth doing; we can just silence the deprecation within QuickEdit. I wonder if it's possible to ignore the deprecation messages only within QuickEdit...

xjm’s picture

Regarding #10, QuickEdit's tests will all be marked legacy when the module is formally deprecated, so yes! That will solve that; just means QE deprecation needs to be complete first.

xjm’s picture

Scoping by module isn't always the best choice, but after taking a quick look at the library definitions, we have the following JS code affected

drupal.editor.admin:
  version: VERSION
  js:
    js/editor.admin.js: {}
  dependencies:
    - core/jquery
    - core/once
    - core/jquery.once.bc
    - core/drupal
    - core/underscore
drupal.filter.filter_html.admin:
  version: VERSION
  js:
    filter.filter_html.admin.js: {}
  dependencies:
    - core/jquery
    - core/once
    - core/jquery.once.bc
    - core/underscore
quickedit.inPlaceEditor.image:
  version: VERSION
  js:
    js/editors/image.js: {}
    js/theme.js: {}
  css:
    component:
      css/editors/image.css: {}
    theme:
      css/editors/image.theme.css: {}
  dependencies:
    - core/jquery
    - core/drupal
    - core/underscore
    - quickedit/quickedit

So Image is only dependent on editor in its QuickEdit integration, which is code that should have been moved to QuickEdit already. 🤔 We should figure out why that hasn't happened yet from the QuickEdit deprecation meta.

Since it's really only two JS files, core/modules/editor/js/editor.admin.js and core/modules/filter/filter.filter_html.admin.js, we should be able to handle the removals in a single issue. That issue can go in anytime. Then, we commit the actual deprecation once QuickEdit is deprecated.

xjm’s picture

Title: Remove dependency on Underscore.js outside of Backbone and mark it internal » [meta] Remove dependency on Underscore.js outside of Backbone and mark it internal
Category: Task » Plan
Issue summary: View changes
Status: Needs work » Active

Updated the IS with a new proposed resolution. We need two child issues filed.

xjm’s picture

Issue summary: View changes

Filed the first child issue for the removal from non-deprecatable code.

xjm’s picture

Issue summary: View changes

 

xjm’s picture

xjm’s picture

Issue tags: +Drupal 9.4 target

 

nod_’s picture

Added #3272872: deprecate underscore and mark it internal to handle the backbone dependency on underscore.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.

xjm’s picture

Issue tags: +Drupal 10 beta should-have

 

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

xjm’s picture

Is there anything left in scope here for D11?

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

catch’s picture

Status: Active » Fixed

This is done, we have #3203920: Replace Contextual Links BackboneJS usage with VanillaJS equivalent one remaining child issue (apart from deprecating toolbar when navigation is stable) to remove backbone too.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

quietone’s picture

Version: 11.x-dev » 11.0.x-dev