Skip to content

A platform for community discussion. Free, open, simple.

FIX: Ensure skip-module JS is transpiled correctly (#21224)

David Taylor6cb733d6c734
diff --git a/lib/discourse_js_processor.rb b/lib/discourse_js_processor.rb
index cd81e6cc9f0..d9c16de74f9 100644
--- a/lib/discourse_js_processor.rb
+++ b/lib/discourse_js_processor.rb
@@ -293,7 +293,7 @@ class DiscourseJsProcessor
"transpile",
source,
{
- skip_module: @skip_module,
+ skipModule: @skip_module,
moduleId: module_name(root_path, logical_path),
filename: logical_path || "unknown",
themeId: theme_id,
diff --git a/spec/lib/discourse_js_processor_spec.rb b/spec/lib/discourse_js_processor_spec.rb
index 2ada7714f9a..24fd32d735b 100644
--- a/spec/lib/discourse_js_processor_spec.rb
+++ b/spec/lib/discourse_js_processor_spec.rb
@@ -35,6 +35,14 @@ RSpec.describe DiscourseJsProcessor do
it "returns false if the header is not present" do
expect(DiscourseJsProcessor.skip_module?("// just some JS\nconsole.log()")).to eq(false)
end
+
+ it "works end-to-end" do
+ source = <<~JS.chomp
+ // discourse-skip-module
+ console.log("hello world");
+ JS
+ expect(DiscourseJsProcessor.transpile(source, "test", "test")).to eq(source)
+ end
end
it "passes through modern JS syntaxes which are supported in our target browsers" do