Skip to content

Breaks confusingly on reexported component classes #26

Description

@ef4

Before colocation, if someone had a component JS that is just a reexport of another component JS:

// app/components/one.js
export default class extends Component {}

// app/templates/components/one.hbs
One

// app/components/two.js
export { default} from './one';

// app/templates/components/two.hbs
Two

This actually gave you two distinct components with the different templates.

But after colocation, templates are associated with JS by value, and since:

import One from './components/one';
import Two from './components/two';
assert.strictEqual(One, Two); // passes

This means they can no longer have different templates. The codemod is unaware of this and just breaks your components.

A better output for the codemod would be rewriting re-exported component classes as extensions:

-export { default } from './one';
+import Component from './one';
+export default class extends Component {};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions