DEV: Allow using .js extension for javascript modules in themes (#9358)
This commit is contained in:
parent
ed74a6c126
commit
3814ca06a8
|
@ -134,7 +134,7 @@ class ThemeField < ActiveRecord::Base
|
|||
filename, extension = name.split(".", 2)
|
||||
begin
|
||||
case extension
|
||||
when "js.es6"
|
||||
when "js.es6", "js"
|
||||
js_compiler.append_module(content, filename)
|
||||
when "hbs"
|
||||
js_compiler.append_ember_template(filename.sub("discourse/templates/", ""), content)
|
||||
|
|
|
@ -173,7 +173,8 @@ HTML
|
|||
|
||||
it "correctly handles extra JS fields" do
|
||||
theme = Fabricate(:theme)
|
||||
js_field = theme.set_field(target: :extra_js, name: "discourse/controllers/discovery.js.es6", value: "import 'discourse/lib/ajax'; console.log('hello');")
|
||||
js_field = theme.set_field(target: :extra_js, name: "discourse/controllers/discovery.js.es6", value: "import 'discourse/lib/ajax'; console.log('hello from .js.es6');")
|
||||
js_2_field = theme.set_field(target: :extra_js, name: "discourse/controllers/discovery-2.js", value: "import 'discourse/lib/ajax'; console.log('hello from .js');")
|
||||
hbs_field = theme.set_field(target: :extra_js, name: "discourse/templates/discovery.hbs", value: "{{hello-world}}")
|
||||
raw_hbs_field = theme.set_field(target: :extra_js, name: "discourse/templates/discovery.hbr", value: "{{hello-world}}")
|
||||
hbr_field = theme.set_field(target: :extra_js, name: "discourse/templates/other_discovery.hbr", value: "{{hello-world}}")
|
||||
|
@ -189,7 +190,7 @@ HTML
|
|||
var themePrefix = function themePrefix(key) {
|
||||
return "theme_translations.#{theme.id}." + key;
|
||||
};
|
||||
console.log('hello');
|
||||
console.log('hello from .js.es6');
|
||||
});
|
||||
JS
|
||||
expect(js_field.reload.value_baked).to eq(expected_js.strip)
|
||||
|
@ -204,6 +205,7 @@ HTML
|
|||
expect(theme.javascript_cache.content).to include('Ember.TEMPLATES["discovery"]')
|
||||
expect(theme.javascript_cache.content).to include('Discourse.RAW_TEMPLATES["discovery"]')
|
||||
expect(theme.javascript_cache.content).to include('define("discourse/controllers/discovery"')
|
||||
expect(theme.javascript_cache.content).to include('define("discourse/controllers/discovery-2"')
|
||||
expect(theme.javascript_cache.content).to include("var settings =")
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue