FEATURE: detect theme errors and catch them (#7589)

* FEATURE: detect theme errors and catch them

* Bump COMPILER_VERSION

* Feedback

* Override eslint no console for one line

* Can't use our ajax method

* remove emoji from translation file
This commit is contained in:
Osama Sayegh
2019-05-24 17:25:55 +03:00
committed by GitHub
parent a51e2271af
commit e20c30987c
7 changed files with 97 additions and 6 deletions

View File

@ -147,9 +147,10 @@ class ThemeJavascriptCompiler
attr_accessor :content
def initialize(theme_id)
def initialize(theme_id, theme_name)
@theme_id = theme_id
@content = +""
@theme_name = theme_name
end
def prepend_settings(settings_hash)
@ -212,12 +213,18 @@ class ThemeJavascriptCompiler
wrapped = <<~PLUGIN_API_JS
(function() {
if ('Discourse' in window && typeof Discourse._registerPluginCode === 'function') {
const __theme_name__ = "#{@theme_name.gsub('"', "\\\"")}";
const settings = Discourse.__container__
.lookup("service:theme-settings")
.getObjectForTheme(#{@theme_id});
const themePrefix = (key) => `theme_translations.#{@theme_id}.${key}`;
Discourse._registerPluginCode('#{version}', api => {
try {
#{es6_source}
} catch(err) {
const rescue = require("discourse/lib/utilities").rescueThemeError;
rescue(__theme_name__, err, api);
}
});
}
})();