Removal of Ember string prototype extensions

AI-generated summary

The discussion revolves around the deprecation of Ember string prototype extensions in Ember 4.x and beyond, with merefield noting that @ember/string appears absent in Ember 5.x, suggesting a temporary fix may not be sustainable. david clarifies that only prototype extensions (e.g., "mystring".capitalize()) are deprecated, not the utility functions themselves — which can still be imported and used as import { capitalize } from "@ember/string". He recommends updating code like the topic-list-previews component accordingly, referencing deprecation docs. david also reports that only a few public plugins need updating, and he’s submitted PRs to fix them: discourse-layouts and discourse-news. He explains that while a patch could restore the deprecated functionality (as detailed in this PR), it’s not ideal due to upstream dependency complexity and the imminent removal anyway. Thus, he formalized the removal in PR #24110. merefield agrees with the strategy and thanks david for the proactive fixes.

Problem is @ember/string is deprecated it appears after Ember 4.x? I can’t see this package in Ember 5.x … so this would just be a bandaid until Discourse rapidly moves into 5.x (which David alluded to here: Upgrading Discourse to Ember 4 - #14 by david)

@David what’s the right call here - use native Javascript (like I have)?

Thanks for the report - we weren’t expecting the JQuery change to affect string prototype extensions, so we’re digging into that :eyes:

As I understand it, it’s just the prototype extensions that are deprecated. So doing something like "mystring".capitalize() will not be allowed.

But you’ll still be able to do stuff like this:

import  { capitalize } from "@ember/string";

capitalize("mystring");

So, that’s what I’d recommend you do in the topic-list-previews component :ok_hand:

(more before/after examples here)

No worries but was surprise to me too :sweat_smile:

I had a look through all-the-themes and all-the-plugins, and there are just a couple of public plugins which need fixing up. I made PRs here: (cc @merefield @angus)

Godfrey did some digging for us into why the JQuery commit triggered this, and his findings are in this PR. So, it’s technically possible for us to restore this functionality, but it involves applying a patch to an upstream dependency which is not ideal.

Given the complexity, and that we’d be removing them in a few months anyway, I think it makes sense to just double-down on the removal now. I’ve formalised that in this PR:

https://github.com/discourse/discourse/pull/24110

Let us know if you have any questions/concerns

Thanks David. I agree with strategy. Kind of you to provide PRs. :pray: