embroider-build / embroider

Compiling Ember apps into spec-compliant, modern Javascript.
MIT License
334 stars 136 forks source link

First-class `<template>`/.gjs/.gts support in @embroider/webpack #1634

Open chancancode opened 11 months ago

chancancode commented 11 months ago

The goal is that eventually @embroider/webpack should support <template> in .gjs/.gts file natively by implementing a webpack loader for these files that does the template() down-leveling, and a built-in babel plugin to further down-level it into the "template() with scope function bag" format, without having to install ember-template-imports.

Implementation wise, we can either depend on ember-template-imports and import its utility functions/babel plugin, or we can bring our own version and disable ember-template-imports if detected, like we do with ember-cli-htmlbars. Either way, we definitely want non-Embroider apps to be able to use the feature via ember-template-imports, and it should at least not error when used in a version of Embroider with native <template> support.

chancancode commented 11 months ago

I was told that the vite experience already supports this out of the box, but I haven't personally used/verified it.

chancancode commented 11 months ago

We also want to make sure this doesn't, by default, apply to incoming v2 addons, as v2 addons are expected to already be published with the "template() with scope function bag" format, at least without some kind of opt-in (see #1635)

NullVoxPopuli commented 11 months ago

I was told that the vite experience already supports this out of the box, but I haven't personally used/verified it.

ye, example: https://github.com/NullVoxPopuli/polaris-starter/blob/main/vite.config.mts#L12