Revert "DEV: Import `MessageBus` from `message-bus-client` instead of globals (#9902)"

Revert “DEV: Import MessageBus from message-bus-client instead of globals (#9902)”

This reverts commit d3bd4821427ddbbf6a3c647117400aa8f8d56e54.

diff --git a/Gemfile.lock b/Gemfile.lock
index f9ecf2a..967f197 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -183,7 +183,7 @@ GEM
       mini_mime (>= 0.1.1)
     maxminddb (0.1.22)
     memory_profiler (0.9.14)
-    message_bus (3.3.0)
+    message_bus (3.2.0)
       rack (>= 1.1.3)
     method_source (1.0.0)
     mini_mime (1.0.2)
diff --git a/app/assets/javascripts/admin/models/backup.js b/app/assets/javascripts/admin/models/backup.js
index 45727a2..2c41e1e 100644
--- a/app/assets/javascripts/admin/models/backup.js
+++ b/app/assets/javascripts/admin/models/backup.js
@@ -2,7 +2,6 @@ import I18n from "I18n";
 import { ajax } from "discourse/lib/ajax";
 import { extractError } from "discourse/lib/ajax-error";
 import EmberObject from "@ember/object";
-import MessageBus from "message-bus-client";
 
 const Backup = EmberObject.extend({
   destroy() {
@@ -12,7 +11,7 @@ const Backup = EmberObject.extend({
   restore() {
     return ajax("/admin/backups/" + this.filename + "/restore", {
       type: "POST",
-      data: { client_id: MessageBus.clientId }
+      data: { client_id: window.MessageBus.clientId }
     });
   }
 });
@@ -39,7 +38,7 @@ Backup.reopenClass({
       type: "POST",
       data: {
         with_uploads: withUploads,
-        client_id: MessageBus.clientId
+        client_id: window.MessageBus.clientId
       }
     }).then(result => {
       if (!result.success) {
diff --git a/app/assets/javascripts/discourse-shims.js b/app/assets/javascripts/discourse-shims.js
deleted file mode 100644
index 2cc9a02..0000000
--- a/app/assets/javascripts/discourse-shims.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// Allow us to import Ember
-define("ember", ["exports"], function(__exports__) {
-  // eslint-disable-next-line no-console
-  console.warn(
-    [
-      "Deprecation notice:",
-      "Use specific `@ember/*` imports instead of `ember`",
-      "(deprecated since Discourse 2.4.0)",
-      "(removal in Discourse 2.5.0)"
-    ].join(" ")
-  );
-
-  __exports__.default = Ember;
-});
-
-define("message-bus-client", [], function() {
-  return window.MessageBus;
-});
diff --git a/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js b/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js
index 045798e..30d1fb4 100644
--- a/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js
+++ b/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js
@@ -9,7 +9,6 @@ import TopicTrackingState, {
 import ScreenTrack from "discourse/lib/screen-track";
 import Site from "discourse/models/site";
 import User from "discourse/models/user";
-import MessageBus from "message-bus-client";
 
 const ALL_TARGETS = ["controller", "component", "route", "model", "adapter"];
 
@@ -28,7 +27,8 @@ export default {
       ALL_TARGETS.forEach(t => app.inject(t, "store", "service:store"));
     }
 
-    app.register("message-bus:main", MessageBus, { instantiate: false });
+    const messageBus = window.MessageBus;
+    app.register("message-bus:main", messageBus, { instantiate: false });
 
     ALL_TARGETS.concat("service").forEach(t =>
       app.inject(t, "messageBus", "message-bus:main")
@@ -39,7 +39,7 @@ export default {
     app.currentUser = currentUser;
 
     const topicTrackingState = TopicTrackingState.create({
-      messageBus: MessageBus,
+      messageBus,
       currentUser
     });
     app.register("topic-tracking-state:main", topicTrackingState, {
diff --git a/app/assets/javascripts/ember-shim.js b/app/assets/javascripts/ember-shim.js
new file mode 100644
index 0000000..1837ae1
--- /dev/null
+++ b/app/assets/javascripts/ember-shim.js
@@ -0,0 +1,14 @@
+// Allow us to import Ember
+define("ember", ["exports"], function(__exports__) {
+  // eslint-disable-next-line no-console
+  console.warn(
+    [
+      "Deprecation notice:",
+      "Use specific `@ember/*` imports instead of `ember`",
+      "(deprecated since Discourse 2.4.0)",
+      "(removal in Discourse 2.5.0)"
+    ].join(" ")
+  );
+
+  __exports__.default = Ember;
+});
diff --git a/app/assets/javascripts/ember_jquery.js b/app/assets/javascripts/ember_jquery.js
index 51f31d5..be7d57d 100644
--- a/app/assets/javascripts/ember_jquery.js
+++ b/app/assets/javascripts/ember_jquery.js
@@ -3,3 +3,4 @@
 //= require jquery
 //= require ember_include
 //= require discourse-loader
+//= require ember-shim
diff --git a/app/assets/javascripts/vendor.js b/app/assets/javascripts/vendor.js
index 5efe954..64119c4 100644
--- a/app/assets/javascripts/vendor.js
+++ b/app/assets/javascripts/vendor.js
@@ -29,4 +29,3 @@
 //= require virtual-dom
 //= require virtual-dom-amd
 //= require intersection-observer
-//= require discourse-shims
diff --git a/app/assets/javascripts/wizard/test/test_helper.js b/app/assets/javascripts/wizard/test/test_helper.js
index 953ba72..c04a59f 100644
--- a/app/assets/javascripts/wizard/test/test_helper.js
+++ b/app/assets/javascripts/wizard/test/test_helper.js
@@ -12,7 +12,7 @@
 //= require ember-template-compiler
 //= require qunit/qunit/qunit
 //= require ember-qunit
-//= require discourse-shims
+//= require ember-shim
 //= require wizard-application
 //= require wizard-vendor
 //= require helpers/assertions
diff --git a/test/javascripts/acceptance/topic-discovery-test.js b/test/javascripts/acceptance/topic-discovery-test.js
index 262a50c..b298918 100644
--- a/test/javascripts/acceptance/topic-discovery-test.js
+++ b/test/javascripts/acceptance/topic-discovery-test.js
@@ -1,6 +1,4 @@
 import { acceptance } from "helpers/qunit-helpers";
-import MessageBus from "message-bus-client";
-
 acceptance("Topic Discovery", {
   settings: {
     show_pinned_excerpt_desktop: true
@@ -87,7 +85,7 @@ QUnit.test("Live update unread state", async assert => {
   );
 
   // Mimic a messagebus message
-  MessageBus.callbacks.filterBy("channel", "/latest").map(c =>
+  window.MessageBus.callbacks.filterBy("channel", "/latest").map(c =>
     c.func({
       message_type: "read",
       topic_id: 11995,
diff --git a/test/javascripts/test_helper.js b/test/javascripts/test_helper.js
index 5e7c155..5646f98 100644
--- a/test/javascripts/test_helper.js
+++ b/test/javascripts/test_helper.js
@@ -17,7 +17,7 @@
 
 // Stuff we need to load first
 //= require vendor
-//= require discourse-shims
+//= require ember-shim
 //= require pretty-text-bundle
 //= require markdown-it-bundle
 //= require application
@@ -55,10 +55,8 @@ sinon.config = {
 
 window.inTestEnv = true;
 
-let MessageBus = require("message-bus-client").default;
-
 // Stop the message bus so we don't get ajax calls
-MessageBus.stop();
+window.MessageBus.stop();
 
 // Trick JSHint into allow document.write
 var d = document;
@@ -193,7 +191,7 @@ QUnit.testDone(function() {
     window.Discourse.__container__
   );
 
-  MessageBus.unsubscribe("*");
+  window.MessageBus.unsubscribe("*");
   delete window.server;
   window.Mousetrap.reset();
 });

GitHub sha: 0f71d38d