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

Drive all template compilation from babel #749

Merged
merged 1 commit into from
Jul 4, 2022
Merged

Drive all template compilation from babel #749

merged 1 commit into from
Jul 4, 2022

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Jun 30, 2022

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.

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](emberjs/rfcs#779), 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](emberjs/babel-plugin-ember-template-compilation#5).

Embroider already [implemented this same pattern](embroider-build/embroider#1010).
@ef4
Copy link
Contributor Author

ef4 commented Jun 30, 2022

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
Copy link
Contributor Author

ef4 commented Jul 4, 2022

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

@ef4 ef4 merged commit 2f2cac9 into master Jul 4, 2022
@delete-merged-branch delete-merged-branch bot deleted the always-use-babel branch July 4, 2022 13:37
ef4 added a commit that referenced this pull request Dec 20, 2023
This is cleanup as an extension to #749. These options stopped really being used at that point.

In the unused options is a complete evaluated copy of the whole ember-template-compiler.js, which is how I noticed this. Loading all that is unnecessary work.
@ef4 ef4 mentioned this pull request Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant