typed-ember / glint

TypeScript powered tooling for Glimmer templates
https://typed-ember.gitbook.io/glint
MIT License
109 stars 51 forks source link

Use `content-tag` in `@glint/environment-ember-template-imports` #609

Closed NullVoxPopuli closed 6 months ago

NullVoxPopuli commented 1 year ago

ember-template-imports is an implementation detail of a feature, where those implementation details are being phased out. For example, ember-template-imports is not used within the v2-addon blueprint (with rollup -- there is a rust plugin that handles the transform, per RFC: https://github.com/emberjs/rfcs/pull/933), and @embroider/vite uses that same plugin in apps, and actually breaks with ember-template-imports present (one too many transforms are happening).

So, I think Glint should also use https://www.npmjs.com/package/content-tag

~~However, because how Glint handles <template> is an implementation details, there is another approach as well. There is a javascript implementation of content-tag used in this PR: https://github.com/ember-cli/eslint-plugin-ember/pull/1920/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519~~

dfreeman commented 1 year ago

It concerns me a little that we already have multiple different libraries cropping up to handle the content tag transform, but it's definitely the case that we should use whatever standard implementation we can rather than continuing to rely on ember-template-imports.

NullVoxPopuli commented 1 year ago

the JS one, it seems is more focused on having consistent line outputs and other meta, whereas the rust-based one is purely concerned with the function of the transform. Idk if the rust-based one could/should also emit that meta, but I asked about it in the eslint-plugin-ember PR, and it seems different needs were... needed. :upside_down_face:

patricklx commented 1 year ago

The js one (ember-template-tag) has 3 main functions. transformForLint, transform, parse. Parse just parses the code and returns meta information about the detected templates. I guess that should be enough?

NullVoxPopuli commented 1 year ago

@patricklx can it do error-tolerant parsing? one thing Glint is lacking right now is the ability to suggest args / blocks / etc while typing, when at a given mid-type the overall template is invalid syntax

patricklx commented 1 year ago

@NullVoxPopuli it's based on babel and it enables error recovery by default. But if you mean template parts, then that has nothing to do with the template detection, but an issue in glimmer parsing

NullVoxPopuli commented 1 year ago

Unblocks gts in Polaris: https://github.com/NullVoxPopuli/polaris-starter/pull/11