DEV: Add support for class properties in babel (#13189)

DEV: Add support for class properties in babel (#13189)

This allows us to start using JS classes instead of Ember’s classes.

diff --git a/app/assets/javascripts/discourse/app/routes/groups-index.js b/app/assets/javascripts/discourse/app/routes/groups-index.js
index 4168466..a054f34 100644
--- a/app/assets/javascripts/discourse/app/routes/groups-index.js
+++ b/app/assets/javascripts/discourse/app/routes/groups-index.js
@@ -1,24 +1,24 @@
 import DiscourseRoute from "discourse/routes/discourse";
 import I18n from "I18n";
 
-export default DiscourseRoute.extend({
+export default class GroupsIndexRoute extends DiscourseRoute {
   titleToken() {
     return I18n.t("groups.index.title");
-  },
+  }
 
-  queryParams: {
+  queryParams = {
     order: { refreshModel: true, replace: true },
     asc: { refreshModel: true, replace: true },
     filter: { refreshModel: true },
     type: { refreshModel: true, replace: true },
     username: { refreshModel: true },
-  },
+  };
 
   model(params) {
     return params;
-  },
+  }
 
   setupController(controller, params) {
     controller.loadGroups(params);
-  },
-});
+  }
+}
diff --git a/lib/discourse_js_processor.rb b/lib/discourse_js_processor.rb
index eaa4035..7fd18e1 100644
--- a/lib/discourse_js_processor.rb
+++ b/lib/discourse_js_processor.rb
@@ -143,9 +143,9 @@ JS
 
       if opts[:module_name] && !@skip_module
         filename = opts[:filename] || 'unknown'
-        "Babel.transform(#{js_source}, { moduleId: '#{opts[:module_name]}', filename: '#{filename}', ast: false, presets: ['es2015'], plugins: [['transform-modules-amd', {noInterop: true}], 'proposal-object-rest-spread', 'proposal-optional-chaining', ['proposal-decorators', {legacy: true} ], exports.WidgetHbsCompiler] }).code"
+        "Babel.transform(#{js_source}, { moduleId: '#{opts[:module_name]}', filename: '#{filename}', ast: false, presets: ['es2015'], plugins: [['transform-modules-amd', {noInterop: true}], 'proposal-object-rest-spread', 'proposal-optional-chaining', ['proposal-decorators', {legacy: true} ], 'proposal-class-properties', exports.WidgetHbsCompiler] }).code"
       else
-        "Babel.transform(#{js_source}, { ast: false, plugins: ['proposal-json-strings', 'proposal-nullish-coalescing-operator', 'proposal-logical-assignment-operators', 'proposal-numeric-separator', 'proposal-optional-catch-binding', 'transform-dotall-regex', 'proposal-unicode-property-regex', 'transform-named-capturing-groups-regex', 'proposal-object-rest-spread', 'proposal-optional-chaining', 'transform-arrow-functions', 'transform-block-scoped-functions', 'transform-block-scoping', 'transform-computed-properties', 'transform-destructuring', 'transform-duplicate-keys', 'transform-for-of', 'transform-function-name', 'transform-literals', 'transform-object-super', 'transform-parameters', 'transform-shorthand-properties', 'transform-spread', 'transform-sticky-regex', 'transform-template-literals', 'transform-typeof-symbol', 'transform-unicode-regex', ['proposal-decorators', {legacy: true}], exports.WidgetHbsCompiler] }).code"
+        "Babel.transform(#{js_source}, { ast: false, plugins: ['proposal-json-strings', 'proposal-nullish-coalescing-operator', 'proposal-logical-assignment-operators', 'proposal-numeric-separator', 'proposal-optional-catch-binding', 'transform-dotall-regex', 'proposal-unicode-property-regex', 'transform-named-capturing-groups-regex', 'proposal-object-rest-spread', 'proposal-optional-chaining', 'transform-arrow-functions', 'transform-block-scoped-functions', 'transform-block-scoping', 'transform-computed-properties', 'transform-destructuring', 'transform-duplicate-keys', 'transform-for-of', 'transform-function-name', 'transform-literals', 'transform-object-super', 'transform-parameters', 'transform-shorthand-properties', 'transform-spread', 'transform-sticky-regex', 'transform-template-literals', 'transform-typeof-symbol', 'transform-unicode-regex', ['proposal-decorators', {legacy: true}], 'proposal-class-properties', exports.WidgetHbsCompiler] }).code"
       end
     end
 

GitHub sha: 2082abbb

1 Like

This commit appears in #13189 which was approved by pmusaraj. It was merged by eviltrout.