Skip to content

Commit a79317f

Browse files
committed
Blog post for template-tag-codemod
1 parent 9bfd0b1 commit a79317f

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

Diff for: content/template-tag-codemod.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: Try out the Template Tag Codemod
3+
authors:
4+
- edward-faulkner
5+
date: 2025-02-21T00:00:00.000Z
6+
tags:
7+
- polaris
8+
- '2025'
9+
- template-tag
10+
- embroider
11+
---
12+
13+
One of the pillars of Ember's upcoming Polaris edition is [Template Tag](https://guides.emberjs.com/release/components/template-tag-format/). Many teams are already writing their components this way and enjoying the improved developer experience. The Template Tag RFC is currently in the "Released" status, and will reach "Recommended" [once we're satisfied that we have sufficient documentation and polish](https://github.com/emberjs/rfcs/pull/1059).
14+
15+
To make it easier for all teams to adopt Template Tag, we've created `@embroider/template-tag-codemod`. The goal of the codemod is fully-reliable conversion to the new format.
16+
17+
_Why is this codemod under the `@embroider` namespace?_
18+
19+
Because Template Tag Codemod is powered by the same backward-compatibility infrastrucutre that we created in Embroider to allow you to adopt modern build tooling. When you build an app with Embroider, Embroider needs to identify, locate, and synthesize import statements for all the components, helpers, and modifiers that you use in your traditional handlebars templates. The Template Tag Codemod does exactly the same thing, except instead of repeating that process every time you do a build, we can do it once-and-for-all and commit the resulting GJS (or GTS for typescript users) files directly into your project. As a result, switching to Template Tag can result in improved build performance for apps that have already adopted Embroider.
20+
21+
This blog post is a call to **try out the codemod**. Even if you're not ready to commit yet to using Template Tag in your app, you can try running the codemod on your app to see what results you get and report bugs that get in your way.
22+
23+
The super-short version of the instructions if you just want to give it a try are:
24+
25+
1. Make sure you don't have any uncommitted changes, because we're about to start mutating all your files!
26+
2. Run `npx @embroider/template-tag-codemod`.
27+
3. (Optional but highly recommended) Use `prettier` (with GJS support enabled) to make the results pretty.
28+
29+
The default behavior will attempt to convert _everything_ in your app, and it will target the most forward-looking output format.
30+
31+
Read the `--help` and the complete instructions [in the README](https://github.com/embroider-build/embroider/tree/main/packages/template-tag-codemod) to:
32+
33+
- limit which files will be converted all at once:
34+
35+
```sh
36+
--renderTests false --routeTemplates false --components app/components/only-these-ones/**/*.hbs
37+
```
38+
39+
- get output that is more compatible with non-bleeding-edge Ember:
40+
41+
```sh
42+
--nativeRouteTemplates false --nativeLexicalThis false
43+
```
44+
45+
- get output that is more compatible with the classic build system:
46+
47+
```sh
48+
--relativeLocalPaths false
49+
```
50+
51+
- produce TypeScript GTS files rather than JavaScript GJS files in cases that are ambiguous between those two choices:
52+
53+
```sh
54+
--defaultFormat gts
55+
```
56+
57+
- customize the naming choices for imported components/helpers/modifiers:
58+
59+
```sh
60+
--renamingRules ./your-rules-here.mjs
61+
```
62+
63+
Please [report issues here](https://github.com/embroider-build/embroider/issues) and ask questions in the #dev-embroider channel on the community Discord.

Diff for: tag/2025.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: 2025
3+
image:
4+
imageMeta:
5+
---
6+
A description for the 2025 tag. If you delete this line it will say
7+
`A collection of X posts` where the description should go.

Diff for: tag/embroider.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Embroider
3+
image:
4+
imageMeta:
5+
---
6+
A description for the Embroider tag. If you delete this line it will say
7+
`A collection of X posts` where the description should go.

Diff for: tag/polaris.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
name: Polaris
3+
image:
4+
imageMeta:
5+
---
6+
Polaris Edition of Ember.js

Diff for: tag/template-tag.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Template Tag
3+
image:
4+
imageMeta:
5+
---
6+
A description for the Template Tag tag. If you delete this line it will say
7+
`A collection of X posts` where the description should go.

0 commit comments

Comments
 (0)