A platform for community discussion. Free, open, simple.
FIX: Restore class-property babel transform for themes (#19883)
David Taylor41f3bb8b5092
diff --git a/app/models/theme.rb b/app/models/theme.rbindex 6b3b2ee7508..808a01a1aa4 100644--- a/app/models/theme.rb+++ b/app/models/theme.rb@@ -6,7 +6,7 @@ require "json_schemer"class Theme < ActiveRecord::Baseinclude GlobalPath- BASE_COMPILER_VERSION = 70+ BASE_COMPILER_VERSION = 71attr_accessor :child_componentsdiff --git a/lib/discourse_js_processor.rb b/lib/discourse_js_processor.rbindex 74167a7ec4b..f0452f0f1b1 100644--- a/lib/discourse_js_processor.rb+++ b/lib/discourse_js_processor.rb@@ -10,6 +10,8 @@ class DiscourseJsProcessor# babel: { debug: true } in ember-cli-build.js, then run `yarn ember build -prod`DISCOURSE_COMMON_BABEL_PLUGINS = [["proposal-decorators", { legacy: true }],+ "proposal-class-properties",+ "proposal-private-methods","proposal-class-static-block","transform-parameters","proposal-export-namespace-from",diff --git a/spec/lib/discourse_js_processor_spec.rb b/spec/lib/discourse_js_processor_spec.rbindex b23dc86536c..90748d3aae4 100644--- a/spec/lib/discourse_js_processor_spec.rb+++ b/spec/lib/discourse_js_processor_spec.rb@@ -41,13 +41,6 @@ RSpec.describe DiscourseJsProcessor doscript = <<~JS.chompoptional?.chaining;const template = func`test`;- class MyClass {- classProperty = 1;- #privateProperty = 1;- #privateMethod() {- console.log("hello world");- }- }let numericSeparator = 100_000_000;logicalAssignment ||= 2;nullishCoalescing ?? 'works';@@ -76,6 +69,24 @@ RSpec.describe DiscourseJsProcessor doJSend+ it "supports decorators and class properties without error" do+ script = <<~JS.chomp+ class MyClass {+ classProperty = 1;+ #privateProperty = 1;+ #privateMethod() {+ console.log("hello world");+ }+ @decorated+ myMethod(){+ }+ }+ JS++ result = DiscourseJsProcessor.transpile(script, "blah", "blah/mymodule")+ expect(result).to include("_applyDecoratedDescriptor")+ end+it "correctly transpiles widget hbs" doresult = DiscourseJsProcessor.transpile(<<~JS, "blah", "blah/mymodule")import hbs from "discourse/widgets/hbs-compiler";