DEV: Apply theme template transforms to colocated components (#18704)
This commit is contained in:
parent
c937b6dd36
commit
cc439cf412
|
@ -232,7 +232,7 @@ class ThemeJavascriptCompiler
|
||||||
transpiler = DiscourseJsProcessor::Transpiler.new
|
transpiler = DiscourseJsProcessor::Transpiler.new
|
||||||
@output_tree << ["#{original_filename}.js", <<~JS]
|
@output_tree << ["#{original_filename}.js", <<~JS]
|
||||||
if ('define' in window) {
|
if ('define' in window) {
|
||||||
#{transpiler.perform(script, "", name).strip}
|
#{transpiler.perform(script, "", name, theme_id: @theme_id).strip}
|
||||||
}
|
}
|
||||||
JS
|
JS
|
||||||
rescue MiniRacer::RuntimeError, DiscourseJsProcessor::TranspileError => ex
|
rescue MiniRacer::RuntimeError, DiscourseJsProcessor::TranspileError => ex
|
||||||
|
|
|
@ -110,6 +110,15 @@ RSpec.describe ThemeJavascriptCompiler do
|
||||||
expect(compiler.raw_content).to include("setComponentTemplate")
|
expect(compiler.raw_content).to include("setComponentTemplate")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "applies theme AST transforms to colocated components" do
|
||||||
|
compiler = ThemeJavascriptCompiler.new(12345678910, 'my theme name')
|
||||||
|
compiler.append_tree(
|
||||||
|
{ "discourse/components/mycomponent.hbs" => '{{theme-i18n "my_translation_key"}}' }
|
||||||
|
)
|
||||||
|
template_compiled_line = compiler.raw_content.lines.find { |l| l.include?('"block":') }
|
||||||
|
expect(template_compiled_line).to include("12345678910")
|
||||||
|
end
|
||||||
|
|
||||||
it "prints error when default export missing" do
|
it "prints error when default export missing" do
|
||||||
compiler.append_tree(
|
compiler.append_tree(
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue