Colocation babel plugin drops class decorators

Open
#442 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
babel, javascript

Research direction

Start with the colocation Babel transform that handles the default export, using the provided AST Explorer example to reproduce the dropped class decorator. Preserve the decorator in the transformed class expression and verify that the generated output retains @dec.

Written by the indexing model from the issue text.

Description

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().

Dominant language
JavaScript
Stars
77
Forks
65
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ember-cli/ember-cli-htmlbars

All issues in ember-cli/ember-cli-htmlbars

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.