From 106c1c317f70c80f968038f0c770ac1d9d480927 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 1 Dec 2023 13:07:57 +0000 Subject: [PATCH] DEV: Restore ember-global deprecation in production (#24664) Even with our patch to the deprecate() macro, this is optimized out of the production build because it's wrapped in an `if(DEBUG)` statement. (https://github.com/davidtaylorhq/ember.js/blob/14c02f53b8/packages/%40ember/-internals/bootstrap/index.ts#L19-L19) --- .../deprecate-shim.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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.js index eee21f17aca..4cfd1d4e627 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 @@ -33,6 +33,29 @@ define("discourse/lib/deprecate-shim", ["exports"], function (exports) { console.warn(`DEPRECATION: ${updatedMessage}`); } ); + + // Patch ember-global deprecation + Object.defineProperty(window, "Ember", { + enumerable: true, + configurable: true, + get() { + require("@ember/debug").deprecate( + "Usage of the Ember Global is deprecated. You should import the Ember module or the specific API instead.", + false, + { + id: "ember-global", + until: "4.0.0", + url: "https://deprecations.emberjs.com/v3.x/#toc_ember-global", + for: "ember-source", + since: { + enabled: "3.27.0", + }, + } + ); + + return require("ember").default; + }, + }); }; });