-
Notifications
You must be signed in to change notification settings - Fork 142
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
Compile Hbs route templates correctly #1856
Conversation
37aba1f
to
3718cf3
Compare
fe48253
to
43cba32
Compare
…o drive development
…specified hbs file
… hbs files instead of js that don't exist in their codebase
43cba32
to
566925f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great 🎉 it's ready to go on the tech side, we need at least some basic docs before we can merge though. It doesn't need to be too in-depth, even a placeholder will do for now.
…ng route templates with a v1 addon
cfd6de2
to
f0cd029
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 🎉
Relates to #1776
Problem
In
main
branch, any hbs that is not colocated with its js is compiled as a template-only component. This behavior breaks the possibility for addons to provide hbs templates that are not components, like route templates.Solution
This PR introduces the possibility of specifying in config the hbs files that should not be compiled as template-only components.
Two different layers transform the standalone
.hbs
in the codebase into a template-only component.js
in the addon build: the Rollup pluginrollup-hbs-plugin
and the Babel plugintemplate-colocation-plugin
. As Rollup config and Babel config are currently not shared, the glob patterns that prevent this compilation from happening will have to be specified for both tools.In the
rollup.config.mjs
of the v2 addon:In the
babel.config.json
of the v2 addon:Required refactorings
Helpers that are not provided by the addon itself need to be explicitly imported.
For instance, let's assume your v1 addon used to have a dependency to ember-root-url and the helper was called in a hbs route template:
You'll be able to build the v2 addon, but when starting the app you'll run into
Attempted to resolve 'root-url', which was expected to be a component or helper, but nothing was found.
To get rid of the error, one solution is to import the helper into the route controller so it's passed down to the template through the context:
(This example doesn't apply to built-in helpers like the
{{component}}
helper, the hbs route template your v2 addon provides can use such a helper and it will continue to work with your classic Ember app.)