Closed
Description
I discovered an issue while pairing with @wycats that I wanted to write down for future discussion.
We were upgrading an Ember app to use Module Unification that had already adopted the JS module API. The migrator produced invalid code for helpers due to the following conflict:
- Helper functions must be wrapped with the
helper
function exported by@ember/component/helper
. - In Module Unification, helpers must be a named export called
helper
.
The migrator produces code that looks like this:
import { helper } from '@ember/components/helper';
function myHelper() { /* ... */ }
// Error: cannot redeclare `helper`
export const helper = helper(myHelper);
One way to fix this is for the migrator to detect this conflict and rename the import (since the export name cannot be changed), e.g. import { helper as emberHelper } from '@ember/components/helper'
. But this is something that everyone will have to type, so we may want to think about this conflict and if there are design changes we want to consider.