A platform for community discussion. Free, open, simple.
DEV: Patch `deprecated-run-loop-and-computed-dot-access` in production (#25074)
David Taylor641c689ac140
diff --git a/.prettierignore b/.prettierignoreindex a30fc1055e3..53e0fcf4247 100644--- a/.prettierignore+++ b/.prettierignore@@ -19,6 +19,7 @@ plugins/**/lib/javascripts/localepublic/!/app/assets/javascripts/discourse/publicvendor/+!app/assets/javascripts/ember-production-deprecations/vendor/app/assets/javascripts/discourse/tests/fixturesspec/node_modules/diff --git a/app/assets/javascripts/ember-production-deprecations/vendor/ember-production-deprecations/deprecate-shim.js b/app/assets/javascripts/ember-production-deprecations/vendor/ember-production-deprecations/deprecate-shim.jsindex 98cace57b31..c72a407b9f4 100644--- a/app/assets/javascripts/ember-production-deprecations/vendor/ember-production-deprecations/deprecate-shim.js+++ b/app/assets/javascripts/ember-production-deprecations/vendor/ember-production-deprecations/deprecate-shim.js@@ -34,13 +34,15 @@ define("discourse/lib/deprecate-shim", ["exports"], function (exports) {});+ const deprecate = require("@ember/debug").deprecate;+// Patch ember-global deprecationif (window.hasOwnProperty("Ember")) {Object.defineProperty(window, "Ember", {enumerable: true,configurable: true,get() {- require("@ember/debug").deprecate(+ deprecate("Usage of the Ember Global is deprecated. You should import the Ember module or the specific API instead.",false,{@@ -58,6 +60,113 @@ define("discourse/lib/deprecate-shim", ["exports"], function (exports) {},});}++ // Patch run.blah deprecations+ // https://github.com/emberjs/ember.js/blob/007fc9eba1/packages/%40ember/runloop/index.js#L748-L808+ const deprecatedRunloopFunctions = [+ "backburner",+ "begin",+ "bind",+ "cancel",+ "debounce",+ "end",+ "hasScheduledTimers",+ "join",+ "later",+ "next",+ "once",+ "schedule",+ "scheduleOnce",+ "throttle",+ "cancelTimers",+ ];++ const run = require("@ember/runloop").run;+ for (const name of deprecatedRunloopFunctions) {+ const currentDescriptor = Object.getOwnPropertyDescriptor(run, name);+ if (currentDescriptor?.value) {+ Object.defineProperty(run, name, {+ get() {+ deprecate(+ `Using \`run.${name}\` has been deprecated. Instead, import the value directly.`,+ false,+ {+ id: "deprecated-run-loop-and-computed-dot-access",+ until: "4.0.0",+ for: "ember-source",+ since: {+ enabled: "3.27.0",+ },+ url: "https://deprecations.emberjs.com/v3.x/#toc_deprecated-run-loop-and-computed-dot-access",+ }+ );+ return currentDescriptor.value;+ },+ });+ }+ }++ // Patch computed.blah deprecations+ // https://github.com/emberjs/ember.js/blob/v3.28.12/packages/%40ember/object/index.js#L60-L118+ const deprecatedComputedFunctions = [+ "alias",+ "and",+ "bool",+ "collect",+ "deprecatingAlias",+ "empty",+ "equal",+ "filterBy",+ "filter",+ "gte",+ "gt",+ "intersect",+ "lte",+ "lt",+ "mapBy",+ "map",+ "match",+ "max",+ "min",+ "none",+ "notEmpty",+ "not",+ "oneWay",+ "reads",+ "or",+ "readOnly",+ "setDiff",+ "sort",+ "sum",+ "union",+ "uniqBy",+ "uniq",+ ];++ const computed = require("@ember/object").computed;+ for (const name of deprecatedComputedFunctions) {+ const currentDescriptor = Object.getOwnPropertyDescriptor(computed, name);+ if (currentDescriptor?.value) {+ Object.defineProperty(computed, name, {+ get() {+ deprecate(+ `Using \`computed.${name}\` has been deprecated. Instead, import the value directly.`,+ false,+ {+ id: "deprecated-run-loop-and-computed-dot-access",+ until: "4.0.0",+ for: "ember-source",+ since: {+ enabled: "3.27.0",+ },+ url: "https://deprecations.emberjs.com/v3.x/#toc_deprecated-run-loop-and-computed-dot-access",+ }+ );+ return currentDescriptor.value;+ },+ });+ }+ }};});