DEV: Remove global Handlebars

DEV: Remove global Handlebars

diff --git a/.eslintignore b/.eslintignore
index 6676467..e877e00 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -13,3 +13,5 @@ vendor/
 test/javascripts/test_helper.js
 test/javascripts/fixtures
 test/javascripts/helpers/assertions.js
+node_modules/
+dist/
diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js
index 9d04586..9ed71e6 100644
--- a/app/assets/javascripts/discourse/app/controllers/composer.js
+++ b/app/assets/javascripts/discourse/app/controllers/composer.js
@@ -352,7 +352,7 @@ export default Controller.extend({
         if (!url || !topicTitle) return;
 
         url = `${location.protocol}//${location.host}${url}`;
-        const link = `[${Handlebars.escapeExpression(topicTitle)}](${url})`;
+        const link = `[${escapeExpression(topicTitle)}](${url})`;
         const continueDiscussion = I18n.t("post.continue_discussion", {
           postLink: link
         });
diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.js
index a49cbaf..3ec58a5 100644
--- a/app/assets/javascripts/discourse/app/controllers/topic.js
+++ b/app/assets/javascripts/discourse/app/controllers/topic.js
@@ -21,6 +21,7 @@ import { userPath } from "discourse/lib/url";
 import showModal from "discourse/lib/show-modal";
 import TopicTimer from "discourse/models/topic-timer";
 import { Promise } from "rsvp";
+import { escapeExpression } from "discourse/lib/utilities";
 
 let customPostMessageCallbacks = {};
 
@@ -976,7 +977,7 @@ export default Controller.extend(bufferedProperty("model"), {
       }
 
       composerController.open(options).then(() => {
-        const title = Handlebars.escapeExpression(this.model.title);
+        const title = escapeExpression(this.model.title);
         const postUrl = `${location.protocol}//${location.host}${post.url}`;
         const postLink = `[${title}](${postUrl})`;
         const text = `${I18n.t("post.continue_discussion", {
diff --git a/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js b/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js
index 3e1505a..bea9bf4 100644
--- a/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js
+++ b/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js
@@ -1,6 +1,7 @@
 import { registerHelpers } from "discourse-common/lib/helpers";
 import RawHandlebars from "discourse-common/lib/raw-handlebars";
 import { registerRawHelpers } from "discourse-common/lib/raw-handlebars-helpers";
+import Handlebars from "handlebars";
 
 export function autoLoadModules(container, registry) {
   Object.keys(requirejs.entries).forEach(entry => {
diff --git a/app/assets/javascripts/discourse/app/initializers/live-development.js b/app/assets/javascripts/discourse/app/initializers/live-development.js
index 38afdbc..fe3d598 100644
--- a/app/assets/javascripts/discourse/app/initializers/live-development.js
+++ b/app/assets/javascripts/discourse/app/initializers/live-development.js
@@ -1,6 +1,7 @@
 import DiscourseURL from "discourse/lib/url";
 import { currentThemeIds, refreshCSS } from "discourse/lib/theme-selector";
 import ENV from "discourse-common/config/environment";
+import Handlebars from "handlebars";
 
 //  Use the message bus for live reloading of components for faster development.
 export default {
diff --git a/app/assets/javascripts/handlebars-shim.js b/app/assets/javascripts/handlebars-shim.js
index e01e17c..85a73c5 100644
--- a/app/assets/javascripts/handlebars-shim.js
+++ b/app/assets/javascripts/handlebars-shim.js
@@ -3,7 +3,13 @@ if (typeof define !== "undefined") {
   define("handlebars", ["exports"], function(__exports__) {
     // It might not be defined server side, which is OK for pretty-text
     if (typeof Handlebars !== "undefined") {
+      // eslint-disable-next-line
       __exports__.default = Handlebars;
     }
   });
+
+  define("handlebars-compiler", ["exports"], function(__exports__) {
+    // eslint-disable-next-line
+    __exports__.default = Handlebars.compile;
+  });
 }
diff --git a/package.json b/package.json
index 0a745f4..95dc2e4 100644
--- a/package.json
+++ b/package.json
@@ -45,7 +45,7 @@
     "chrome-launcher": "^0.12.0",
     "chrome-remote-interface": "^0.25",
     "ember-template-lint": "^2.5.2",
-    "eslint-config-discourse": "1.1.0",
+    "eslint-config-discourse": "1.1.1",
     "eslint-plugin-discourse-ember": "0.0.3",
     "lodash-cli": "https://github.com/lodash-archive/lodash-cli.git",
     "pretender": "^1.6",
diff --git a/test/javascripts/acceptance/raw-plugin-outlet-test.js b/test/javascripts/acceptance/raw-plugin-outlet-test.js
index 62ea960..8f104ce 100644
--- a/test/javascripts/acceptance/raw-plugin-outlet-test.js
+++ b/test/javascripts/acceptance/raw-plugin-outlet-test.js
@@ -1,10 +1,11 @@
 import { acceptance } from "helpers/qunit-helpers";
+import compile from "handlebars-compiler";
 
 const CONNECTOR =
   "javascripts/raw-test/connectors/topic-list-before-status/lala";
 acceptance("Raw Plugin Outlet", {
   beforeEach() {
-    Discourse.RAW_TEMPLATES[CONNECTOR] = Handlebars.compile(
+    Discourse.RAW_TEMPLATES[CONNECTOR] = compile(
       `<span class='topic-lala'>{{context.topic.id}}</span>`
     );
   },
diff --git a/yarn.lock b/yarn.lock
index 4383920..742a3bd 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -969,10 +969,10 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
   resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
   integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
 
-eslint-config-discourse@1.1.0:
-  version "1.1.0"
-  resolved "https://registry.yarnpkg.com/eslint-config-discourse/-/eslint-config-discourse-1.1.0.tgz#1f2b1ffd6064c579bc74eca63420bd3cd5732950"
-  integrity sha512-y2osWnbIi/CS2hDm61K6vdYA5vEuFJRetI2UFlEo8rQCx2t46XUd+FkgAvBy0nzLSm7ELBKru5qYKveKFF6eAg==
+eslint-config-discourse@1.1.1:
+  version "1.1.1"
+  resolved "https://registry.yarnpkg.com/eslint-config-discourse/-/eslint-config-discourse-1.1.1.tgz#8a7f7f6f1a388b0e88f5b79145ae2a8b4a13e3d4"
+  integrity sha512-b3dp9DOcXYWkPQpXms/bMDy0Scb6DO/nZAAsl5I9yTNhtkx96zZMTp9QEyC8QaCXOTUpIXEE6V+Mpyjtsk3gWg==
   dependencies:
     babel-eslint "^8.2"
     eslint "^4.19"

GitHub sha: f182e61d

1 Like