diff --git a/lib/theme_javascript_compiler.rb b/lib/theme_javascript_compiler.rb index 1668168145b..25975dbb60f 100644 --- a/lib/theme_javascript_compiler.rb +++ b/lib/theme_javascript_compiler.rb @@ -232,7 +232,7 @@ class ThemeJavascriptCompiler transpiler = DiscourseJsProcessor::Transpiler.new @output_tree << ["#{original_filename}.js", <<~JS] if ('define' in window) { - #{transpiler.perform(script, "", name).strip} + #{transpiler.perform(script, "", name, theme_id: @theme_id).strip} } JS rescue MiniRacer::RuntimeError, DiscourseJsProcessor::TranspileError => ex diff --git a/spec/lib/theme_javascript_compiler_spec.rb b/spec/lib/theme_javascript_compiler_spec.rb index 116e4ee3e7f..8d94ed72d5b 100644 --- a/spec/lib/theme_javascript_compiler_spec.rb +++ b/spec/lib/theme_javascript_compiler_spec.rb @@ -110,6 +110,15 @@ RSpec.describe ThemeJavascriptCompiler do expect(compiler.raw_content).to include("setComponentTemplate") 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 compiler.append_tree( {