A platform for community discussion. Free, open, simple.
A couple important Ember CLI fixes (#12345)
Robin Ward70363469656a
diff --git a/app/assets/javascripts/discourse/app/index.html b/app/assets/javascripts/discourse/app/index.htmlindex 28558df7ded..65220326aa9 100644--- a/app/assets/javascripts/discourse/app/index.html+++ b/app/assets/javascripts/discourse/app/index.html@@ -27,6 +27,15 @@<div id='offscreen-content'></div>+ <script>+ document.addEventListener("discourse-booted", (e) => {+ const config = e.detail;+ const app = require(`${config.modulePrefix}/app`)["default"].create(+ config+ );+ app.start();+ });+ </script>{{bootstrap-content-for "hidden-login-form"}}{{bootstrap-content-for "preloaded"}}diff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js b/app/assets/javascripts/discourse/lib/bootstrap-json/index.jsindex d75ea398fa2..35c42809dd0 100644--- a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js+++ b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js@@ -20,6 +20,25 @@ function htmlTag(buffer, bootstrap) {buffer.push(`<html lang="${bootstrap.html_lang}"${classList}>`);}+function bareStylesheets(buffer, bootstrap) {+ (bootstrap.stylesheets || []).forEach((s) => {+ if (s.theme_id) {+ return;+ }+ let attrs = [];+ if (s.media) {+ attrs.push(`media="${s.media}"`);+ }+ if (s.target) {+ attrs.push(`data-target="${s.target}"`);+ }+ let link = `<link rel="stylesheet" type="text/css" href="${+ s.href+ }" ${attrs.join(" ")}></script>\n`;+ buffer.push(link);+ });+}+function head(buffer, bootstrap) {if (bootstrap.csrf_token) {buffer.push(`<meta name="csrf-param" buffer="authenticity_token">`);@@ -72,9 +91,13 @@ function head(buffer, bootstrap) {buffer.push(bootstrap.html.before_head_close);}+function localeScript(buffer, bootstrap) {+ buffer.push(`<script src="${bootstrap.locale_script}"></script>`);+}+function beforeScriptLoad(buffer, bootstrap) {buffer.push(bootstrap.html.before_script_load);- buffer.push(`<script src="${bootstrap.locale_script}"></script>`);+ localeScript(buffer, bootstrap);(bootstrap.extra_locales || []).forEach((l) =>buffer.push(`<script src="${l}"></script>`));@@ -119,6 +142,8 @@ const BUILDERS = {"hidden-login-form": hiddenLoginForm,preloaded: preloaded,"body-footer": bodyFooter,+ "locale-script": localeScript,+ "bare-stylesheets": bareStylesheets,};function replaceIn(bootstrap, template, id) {@@ -136,11 +161,11 @@ function applyBootstrap(bootstrap, template) {return template;}-function decorateIndex(baseUrl, headers) {+function decorateIndex(assetPath, baseUrl, headers) {// eslint-disable-next-linereturn new Promise((resolve, reject) => {fs.readFile(- path.join(process.cwd(), "dist", "index.html"),+ path.join(process.cwd(), "dist", assetPath),"utf8",(err, template) => {getJSON(`${baseUrl}/bootstrap.json`, null, headers)@@ -190,9 +215,13 @@ module.exports = {}if (!isFile) {+ assetPath = "index.html";+ }++ if (assetPath.endsWith("index.html")) {let template;try {- template = await decorateIndex(proxy, req.headers);+ template = await decorateIndex(assetPath, proxy, req.headers);} catch (e) {template = `<html>@@ -201,7 +230,7 @@ module.exports = {</html>`;}- res.send(template);+ return res.send(template);}}} finally {diff --git a/app/assets/javascripts/discourse/public/assets/scripts/discourse-boot.js b/app/assets/javascripts/discourse/public/assets/scripts/discourse-boot.jsindex 903de3dba6a..a4811cab76a 100644--- a/app/assets/javascripts/discourse/public/assets/scripts/discourse-boot.js+++ b/app/assets/javascripts/discourse/public/assets/scripts/discourse-boot.js@@ -177,6 +177,6 @@const config = JSON.parse(decodeURIComponent(element.getAttribute("content")));- const app = require(`${config.modulePrefix}/app`)["default"].create(config);- app.start();+ const event = new CustomEvent("discourse-booted", { detail: config });+ document.dispatchEvent(event);})();diff --git a/app/assets/javascripts/discourse/tests/index.html b/app/assets/javascripts/discourse/tests/index.htmlindex 526fa4bef6a..c5213f1b10c 100644--- a/app/assets/javascripts/discourse/tests/index.html+++ b/app/assets/javascripts/discourse/tests/index.html@@ -27,6 +27,8 @@}</style>+ {{bootstrap-content-for "locale-script"}}+ {{bootstrap-content-for "bare-stylesheets"}}</head><body>{{content-for "body"}}