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

This regressed in 7e74dd0afea996d272c391bff9b0a516e7e323db, and was causing issues with 2fa security keys on the email verification route
This commit is contained in:
David Taylor 2023-04-24 17:39:02 +01:00 committed by GitHub
parent cd88af8876
commit 6cb733d6c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -293,7 +293,7 @@ class DiscourseJsProcessor
"transpile", "transpile",
source, source,
{ {
skip_module: @skip_module, skipModule: @skip_module,
moduleId: module_name(root_path, logical_path), moduleId: module_name(root_path, logical_path),
filename: logical_path || "unknown", filename: logical_path || "unknown",
themeId: theme_id, themeId: theme_id,

View File

@ -35,6 +35,14 @@ RSpec.describe DiscourseJsProcessor do
it "returns false if the header is not present" do it "returns false if the header is not present" do
expect(DiscourseJsProcessor.skip_module?("// just some JS\nconsole.log()")).to eq(false) expect(DiscourseJsProcessor.skip_module?("// just some JS\nconsole.log()")).to eq(false)
end 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 end
it "passes through modern JS syntaxes which are supported in our target browsers" do it "passes through modern JS syntaxes which are supported in our target browsers" do