DEV: Add production-mode shim for Em deprecation (#25109)

This commit is contained in:
David Taylor 2024-01-03 10:39:59 +00:00 committed by GitHub
parent 451581d50a
commit 6e7356e7c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,29 +37,31 @@ define("discourse/lib/deprecate-shim", ["exports"], function (exports) {
const deprecate = require("@ember/debug").deprecate; const deprecate = require("@ember/debug").deprecate;
// Patch ember-global deprecation // Patch ember-global deprecation
if (window.hasOwnProperty("Ember")) { ["Ember", "Em"].forEach((key) => {
Object.defineProperty(window, "Ember", { if (window.hasOwnProperty(key)) {
enumerable: true, Object.defineProperty(window, key, {
configurable: true, enumerable: true,
get() { configurable: true,
deprecate( get() {
"Usage of the Ember Global is deprecated. You should import the Ember module or the specific API instead.", deprecate(
false, `Usage of the ${key} Global is deprecated. You should import the Ember module or the specific API instead.`,
{ false,
id: "ember-global", {
until: "4.0.0", id: "ember-global",
url: "https://deprecations.emberjs.com/v3.x/#toc_ember-global", until: "4.0.0",
for: "ember-source", url: "https://deprecations.emberjs.com/v3.x/#toc_ember-global",
since: { for: "ember-source",
enabled: "3.27.0", since: {
}, enabled: "3.27.0",
} },
); }
);
return require("ember").default; return require("ember").default;
}, },
}); });
} }
});
// Patch run.blah deprecations // Patch run.blah deprecations
// https://github.com/emberjs/ember.js/blob/007fc9eba1/packages/%40ember/runloop/index.js#L748-L808 // https://github.com/emberjs/ember.js/blob/007fc9eba1/packages/%40ember/runloop/index.js#L748-L808