Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks confusingly on reexported component classes #26

Open
ef4 opened this issue Aug 4, 2023 · 0 comments
Open

Breaks confusingly on reexported component classes #26

ef4 opened this issue Aug 4, 2023 · 0 comments

Comments

@ef4
Copy link

ef4 commented Aug 4, 2023

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 {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant