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

Inline HBS Reform #462

Closed
wants to merge 21 commits into from
Closed

Inline HBS Reform #462

wants to merge 21 commits into from

Conversation

ef4
Copy link

@ef4 ef4 commented Jul 8, 2021

This accompanies embroider-build/embroider#893 and similar PRs to ember-cli-htmlbars and ember-template-imports will be forthcoming.

This is a radical simplification of this plugin, along with a full port to typescript. The main reason we can simplify is that we're dropping support for Ember versions that need modules-api-polyfill (a source of much pain and complexity when it comes to composing babel plugins).

I have confirmed that other consumers of template compilation like Embroider and ember-template-imports can use their own standalone babel plugins that compose nicely with this one, so they can emit precompileTemplate, and this plugin will handle that with one shared implementation.

Along with this, I'd prefer to rename this package @ember/template-compilation, because that's its public API:

import { precompileTemplate } from '@ember/template-compilation';

The older patterns like import { hbs } from 'ember-cli-htmlbars' are still available, but are understood to be sugar for precompile, because precompile is a superset of all the rest and it should be understood as the foundational primitive for all template compilation in Ember. Even standalone .hbs files are conceptually sugar for export default precompileTemplate(...). The actual rename will presumably need an RFC.

This cuts all the special ember-template-imports support from this plugin, since it doesn't belong here and was only entangled due to the cruft we have removed. I'll have a PR to ember-template-imports porting its code back into there.

In the process of porting to typescript, several real edge case crashes were found, like not handling spread elements within the options we parse.

There was also a whole dance of registerRefs that was having no effect at all, perhaps it was only needed on older babel versions.

@pzuraq
Copy link

pzuraq commented Aug 7, 2021

There was also a whole dance of registerRefs that was having no effect at all, perhaps it was only needed on older babel versions

I believe this was necessary for when this plugin had to layer cleanly on top of/before the Ember modules polyfill. There ended up being so many edge cases there that we had to just ship modules, or it wouldn't fully work 🙃

@ef4
Copy link
Author

ef4 commented Oct 13, 2021

This branch is instead becoming a separate repo:

https://github.com/emberjs/babel-plugin-ember-template-compilation

  • because this is a more appropriate name for what the plugin has evolved into
  • because having a separate package will ease the migration
    • because ember-cli-htmlbars will want to depend on both babel-plugin-htmlbars-inline-precompile (for ember < 3.27) and babel-plugin-ember-template-compilation (for ember >= 3.27).

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

Successfully merging this pull request may close these issues.

2 participants