ember-cli-htmlbars icon indicating copy to clipboard operation
ember-cli-htmlbars copied to clipboard

Colocation babel plugin drops class decorators

Open ef4 opened this issue 5 years ago • 2 comments

With an input like

import hbs from 'ember-cli-htmlbars-inline-precompile';
const __COLOCATED_TEMPLATE__ = hbs`{{yield}}`;
export default @dec class {}

The class decorator @dec gets dropped:

import hbs from 'ember-cli-htmlbars-inline-precompile';
const __COLOCATED_TEMPLATE__ = hbs`{{yield}}`;
export default Ember._setComponentTemplate(__COLOCATED_TEMPLATE__, class {});

See example https://astexplorer.net/#/gist/4fb9360091ca6422ca0f9e4ee8ef9505/90046a397d94a8ccf8e97c17fd4f2d0cb867a129

I think all that is required to fix is to pass defaultExportDeclaration.decorators as the fourth argument to t.classExpression().

ef4 avatar Jan 23 '20 19:01 ef4

awesome, thank you for reporting @ef4!

rwjblue avatar Feb 06 '20 21:02 rwjblue

We should also confirm that we don't loose comments (IIRC comments are sometimes attached to the node like this).

rwjblue avatar Feb 06 '20 21:02 rwjblue