You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generated helper does not work out of box under Module Unification feature #17556
When you run ember generate helper hello-helper, it generates two files (hello-helper.js and hello-helper-test.js under src/ui/components folder.
The content of hello-heper.js is following:
import { helper } from '@ember/component/helper';
export function helloHelper(params/*, hash*/) {
return params;
}
export default helper(helloHelper);
Above generated code does not work. During runtime, Ember outputs following error in console: Uncaught Error: Compile Error: hello-helper is not a helper at opcode-compiler.js:294
To make it work, you need to change how helper exports. If you modify hello-helper.js with following code, it works.
import { helper as buildHelper } from '@ember/component/helper';
export function helloHelper(params/*, hash*/) {
return params;
}
export const helper = buildHelper(helloHelper);
Thanks @NullVoxPopuli for helping me out on Discord to solve this problem. I can update blueprint for helper and submit a PR to fix this if no one is addressing this issue under Module Unification meta issue.
The helper blueprint creates the same content for both layouts (Classic and MU), it just places the files in different locations. As far as I know, this is correct and helpers should have the same API either for the Classic or MU layout. , or am I missing something?
@NullVoxPopuli could you provide more info about why this change was needed?
I think it's just the convention going forward.
I wouldn't be able to point to an RFC or anything, but as far as I've known, this has always been required of the octane layout.
(but to technically answer your question (not sure exactly which aspect you're asking), the template helper resolver thing requires a named helper export
@axyxnz np, I have lately modified the blueprints, so I can take a stab on it. Just let me know if you want to pass me the issue or need any support (you can reach me in Discord).
Activity
rwjblue commentedon Feb 16, 2019
/cc @ppcano
ppcano commentedon Feb 16, 2019
Thanks for reporting the issue.
The helper blueprint creates the same content for both layouts (Classic and MU), it just places the files in different locations. As far as I know, this is correct and
helpersshould have the same API either for the Classic or MU layout. , or am I missing something?@NullVoxPopuli could you provide more info about why this change was needed?
NullVoxPopuli commentedon Feb 16, 2019
I think it's just the convention going forward.
I wouldn't be able to point to an RFC or anything, but as far as I've known, this has always been required of the octane layout.
(but to technically answer your question (not sure exactly which aspect you're asking), the template helper resolver thing requires a named
helperexportppcano commentedon Feb 17, 2019
Thanks, I found #16361 describing the public API.
The guides should also be updated, I have added a comment at ember-learn/guides-source#460 (comment)
@axyxnz
A PR would be very much welcomed. Please, let me know if you are gonna work on it.
A possible implementation could be:
blueprints/helper/mu-fileswith the new content.filesPathonblueprint/helper/index.jsin app - octaneandin addon - octane.For reference, look at b0645bd
The commit duplicates the existing
module-unificationtest with theoctaneenvironment.axyxnz commentedon Feb 19, 2019
@ppcano I never worked on Ember repository so it may take some time for me to implement the solution.
ppcano commentedon Feb 19, 2019
@axyxnz np, I have lately modified the blueprints, so I can take a stab on it. Just let me know if you want to pass me the issue or need any support (you can reach me in Discord).
ppcano commentedon Feb 28, 2019
@axyxnz any progress? I am available to fix this issue.
axyxnz commentedon Feb 28, 2019
Hey, sorry. I got busy with work stuff. You can implement the fix as I won't able to get to this issue til this weekend.
Fix helper blueprint for module unification
ppcano commentedon Mar 3, 2019
#17689 has fixed it. This issue should be closed.