diff --git a/app/assets/javascripts/discourse.js b/app/assets/javascripts/discourse.js index 2bddc91c2f6..70a5af9e4ab 100644 --- a/app/assets/javascripts/discourse.js +++ b/app/assets/javascripts/discourse.js @@ -140,3 +140,18 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, { // TODO: Remove this, it is in for backwards compatibiltiy with plugins Discourse.HasCurrentUser = {}; + +function proxyDep(propName, moduleFunc, msg) { + if (Discourse.hasOwnProperty(propName)) { return; } + Object.defineProperty(Discourse, propName, { + get: function() { + msg = msg || "import the module"; + Ember.warn("DEPRECATION: `Discourse." + propName + "` is deprecated, " + msg + "."); + return moduleFunc(); + } + }); +} + +proxyDep('computed', function() { return require('discourse/lib/computed') }); +proxyDep('Formatter', function() { return require('discourse/lib/formatter') }); +proxyDep('PageTracker', function() { return require('discourse/lib/page-tracker').default }); diff --git a/app/assets/javascripts/discourse/initializers/load-all-helpers.js.es6 b/app/assets/javascripts/discourse/initializers/load-all-helpers.js.es6 index 81c84f11b10..f9ec0d71c75 100644 --- a/app/assets/javascripts/discourse/initializers/load-all-helpers.js.es6 +++ b/app/assets/javascripts/discourse/initializers/load-all-helpers.js.es6 @@ -7,28 +7,5 @@ export default { require(entry, null, null, true); } }); - - // TODO: Once things have migrated remove these - if (!Discourse.hasOwnProperty('computed')) { - const computed = require('discourse/lib/computed'); - Object.defineProperty(Discourse, 'computed', { - get: function() { - Ember.warn('DEPRECATION: `Discourse.computed` is deprecated, import the functions as needed.'); - return computed; - } - }); - } - - if (!Discourse.hasOwnProperty('Formatter')) { - const Formatter = require('discourse/lib/formatter'); - Object.defineProperty(Discourse, 'Formatter', { - get: function() { - Ember.warn('DEPRECATION: `Discourse.Formatter` is deprecated, import the formatters as needed.'); - return Formatter; - } - }); - } - - } };