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

Support older Ember versions? #5

Open
chancancode opened this issue May 22, 2020 · 0 comments
Open

Support older Ember versions? #5

chancancode opened this issue May 22, 2020 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@chancancode
Copy link
Contributor

Given some effort, this can probably made to work with older LTS versions. The implementation strategy is actually straightforward and just transpiles the templates into basic syntax like {{#if}} {{else}} and helper calls.

If there is demand to support older Ember version, we can probably make it happen. I am unlikely to do it myself, but would be happy to guide someone else to do it. Here are some pointers.

So far, the main limitation is that it requires a tiny change in the tokenizer in order to parse named blocks correctly. Without this change, <:foo> is parsed into the same thing as <foo>. This change has been backported to the latest version of LTS 3.12 and 3.16.

On older LTS, backporting the change is not an option. Instead, we can do one of these:

  1. Try to monkey patch the tokenizer change into the template compiler at runtime. This is plausible but the code is nested deep inside the template compiler's module and it's not trivial to get too.

  2. Try to use the source location information on the ElementNode and read back into the original source to see if there was a colon in there. This could work, but I'm not sure how robust it will be, given the source location is not super reliable on old versions of the template compiler, and it may be completely wrong if it was touched by other AST plugins before us.

  3. Bundle a recent version of the ember or glimmer template compiler, use it a broccoli build step to preprocess all template files – parse it with the new template compiler and our AST plugin, then reprint the result as handlebars source, before passing them into the version of ember template compiler used by the app. This is probably the most robust solution, and building out the infrastructure to do this is something that could benefit future work in polyfilling template features as well as helping V2 addons. Unfortunately, I'm not exactly sure how to do this myself, so you will probably need to ask for help from someone on the Ember CLI team.

@chancancode chancancode added help wanted Extra attention is needed enhancement New feature or request labels May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant