mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Restore class-property babel transform for themes (#19883)
This seems to be required for decorators to work on class properties. Followup to 624f4a7de9
This commit is contained in:
parent
624f4a7de9
commit
41f3bb8b50
@ -6,7 +6,7 @@ require "json_schemer"
|
|||||||
class Theme < ActiveRecord::Base
|
class Theme < ActiveRecord::Base
|
||||||
include GlobalPath
|
include GlobalPath
|
||||||
|
|
||||||
BASE_COMPILER_VERSION = 70
|
BASE_COMPILER_VERSION = 71
|
||||||
|
|
||||||
attr_accessor :child_components
|
attr_accessor :child_components
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ class DiscourseJsProcessor
|
|||||||
# babel: { debug: true } in ember-cli-build.js, then run `yarn ember build -prod`
|
# babel: { debug: true } in ember-cli-build.js, then run `yarn ember build -prod`
|
||||||
DISCOURSE_COMMON_BABEL_PLUGINS = [
|
DISCOURSE_COMMON_BABEL_PLUGINS = [
|
||||||
["proposal-decorators", { legacy: true }],
|
["proposal-decorators", { legacy: true }],
|
||||||
|
"proposal-class-properties",
|
||||||
|
"proposal-private-methods",
|
||||||
"proposal-class-static-block",
|
"proposal-class-static-block",
|
||||||
"transform-parameters",
|
"transform-parameters",
|
||||||
"proposal-export-namespace-from",
|
"proposal-export-namespace-from",
|
||||||
|
@ -41,13 +41,6 @@ RSpec.describe DiscourseJsProcessor do
|
|||||||
script = <<~JS.chomp
|
script = <<~JS.chomp
|
||||||
optional?.chaining;
|
optional?.chaining;
|
||||||
const template = func`test`;
|
const template = func`test`;
|
||||||
class MyClass {
|
|
||||||
classProperty = 1;
|
|
||||||
#privateProperty = 1;
|
|
||||||
#privateMethod() {
|
|
||||||
console.log("hello world");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let numericSeparator = 100_000_000;
|
let numericSeparator = 100_000_000;
|
||||||
logicalAssignment ||= 2;
|
logicalAssignment ||= 2;
|
||||||
nullishCoalescing ?? 'works';
|
nullishCoalescing ?? 'works';
|
||||||
@ -76,6 +69,24 @@ RSpec.describe DiscourseJsProcessor do
|
|||||||
JS
|
JS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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" do
|
it "correctly transpiles widget hbs" do
|
||||||
result = DiscourseJsProcessor.transpile(<<~JS, "blah", "blah/mymodule")
|
result = DiscourseJsProcessor.transpile(<<~JS, "blah", "blah/mymodule")
|
||||||
import hbs from "discourse/widgets/hbs-compiler";
|
import hbs from "discourse/widgets/hbs-compiler";
|
||||||
|
Loading…
Reference in New Issue
Block a user