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

TemplateCompiler fixes / improvements (avoid monkey patch for Ember 3.27+) #700

Merged

Conversation

rwjblue
Copy link
Collaborator

@rwjblue rwjblue commented Feb 26, 2021

At a high level this PR does a few things:

  • Avoid monkey patch template compiler on Ember >= 3.27
  • Refactor template compiler patches to simplify and make it clearer to know when we can remove each patch
  • Use Node's builtin vm.createContext to prevent global mutation during template compiler evaluation
  • Remove references to the deprecated registerPlugin template compiler API (we were not using it)
  • Update TemplateCompiler#applyTransforms to be safer for source -> source transformations (e.g. preserving entity encoding)

* extract a helper for introspecting ember version from the source
  comment
* makes it clearer what changes are needed for each Ember version
New API exposed in emberjs/ember.js#19426
enables us to avoid munging with the template compiler internals.
`registerPlugin` / `unregisterPlugin` have been deprecated (they rely on
global mutation, and are slated for removal in Ember 4.0).
This does two main things:

* removes processing of HTML entities
* disables Handlebars whitespace removal for certain contexts

These changes are important because it allows our source -> source
transformation to remain stable in more circumstances.
This API was introduced in
emberjs/ember.js#19426 and allows us to avoid
Ember's own AST transform plugins.

The changes here are safe across all Ember version ranges (in both cases
applyTransforms avoids running Ember's own transforms).
@ef4 ef4 merged commit ed5e9bc into embroider-build:master Feb 28, 2021
@ef4
Copy link
Contributor

ef4 commented Feb 28, 2021

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants