ember-cli / ember-cli-htmlbars

MIT License
77 stars 66 forks source link

Drive all template compilation from babel #749

Closed ef4 closed 2 years ago

ef4 commented 2 years ago

Classically, standalone templates got a dedicated preprocessor that had nothing to do with Javascript transpilation.

Later came inline templates that appear inside Javascript. Those were handled as a totally separate code path from the standalone templates. To this day, there are two different code paths for handling these two cases.

But at this point, templates-inside-javascript are the foundational primitive that is aligned with where Ember is heading, because they have access to Javascript scope and this solves a lot of problems.

We can treat standalone HBS as just a degenerate kind of JS that is easily up-compiled via a pure function, allowing them to go down the Javascript code path and allowing us to drop all the old code path.

This also makes it easier to support new features like AST transforms that can manipulate Javascript scope.

Embroider already implemented this same pattern.

ef4 commented 2 years ago

Publishing this as 6.1.0-alpha.0 so we can try it in some real apps. I don't feel super confident that the test coverage here would catch every weird behavior people are relying on.

ef4 commented 2 years ago

After feedback from several apps that had no problems this looks good.