Repository: ember-cli/ember-cli
Pull request #10447 (2024-03-05 18:51:18)

[ENHANCEMENT] Add gjs/gts support for apps and addons
Adds setting up template tag dependencies for new Ember apps. (dependencies, configs)

Open question:
- Do we want this behind a flag?
  - Any downsides to just _always_ enabling it? This should have no real impact on existing apps, even if the format is not used.
  - Upside of not having a flag is keeping the API surface small, and preventing complicated scenarios. E.g. there's a mix in options depending if `typescript` is enabled or not, making this complexer.

Related: https://github.com/emberjs/tracking-polaris/issues/33

NullVoxPopuli: > Any downsides to just always enabling it? 

I don't think so. 
DirkLachowski: Is support for template tag format  for `ember g component` part of this issue?
Windvis: @DirkLachowski The component blueprint lives in the ember-source repo, so a PR would be needed there. Good question though, I think that might be missing from the polaris tracking issue.
Windvis: So skimming through the comments, the remaining blockers are:

- remove the flag, we don't need one
- update the eslint config so it uses overrides for everything

Anything else?

I can help finish this.
NullVoxPopuli: Linting covered here: https://github.com/ember-cli/ember-cli/pull/10516

Patch:
diff --git a/blueprints/addon/files/tsconfig.json b/blueprints/addon/files/tsconfig.json
index 7b83c0d8b..cf5217e56 100644
--- a/blueprints/addon/files/tsconfig.json
+++ b/blueprints/addon/files/tsconfig.json
@@ -1,5 +1,8 @@
 {
   "extends": "@tsconfig/ember/tsconfig.json",
+  "glint": {
+    "environment": ["ember-loose", "ember-template-imports"]
+  },
   "compilerOptions": {
     // The combination of `baseUrl` with `paths` allows Ember's classic package
     // layout, which is not resolvable with the Node resolution algorithm, to
diff --git a/blueprints/addon/index.js b/blueprints/addon/index.js
index ac2ed3678..23899dbf0 100644
--- a/blueprints/addon/index.js
+++ b/blueprints/addon/index.js
@@ -68,6 +68,9 @@ module.exports = {
     contents.dependencies['ember-cli-htmlbars'] = contents.devDependencies['ember-cli-htmlbars'];
     delete contents.devDependencies['ember-cli-htmlbars'];
 
+    contents.dependencies['ember-template-imports'] = contents.devDependencies['ember-template-imports'];
+    delete contents.devDependencies['ember-template-imports'];
+
     // 95% of addons don't need ember-data or ember-fetch, make them opt-in instead
     let deps = Object.keys(contents.devDependencies);
     for (let depName of deps) {
diff --git a/blueprints/app/files/.prettierrc.js b/blueprints/app/files/.prettierrc.js
index 8d067814c..7c49e9dee 100644
--- a/blueprints/app/files/.prettierrc.js
+++ b/blueprints/app/files/.prettierrc.js
@@ -4,7 +4,7 @@ module.exports = {
   plugins: ['prettier-plugin-ember-template-tag'],
   overrides: [
     {
-      files: '*.{js,ts,mjs,mts,cjs,cts}',
+      files: '*.{js,gjs,ts,gts,mjs,mts,cjs,cts}',
       options: {
         singleQuote: true,
       },
diff --git a/blueprints/app/files/package.json b/blueprints/app/files/package.json
index 662becb84..d2cbef770 100644
--- a/blueprints/app/files/package.json
+++ b/blueprints/app/files/package.json
@@ -49,6 +49,7 @@
     "@glimmer/component": "^1.1.2",
     "@glimmer/tracking": "^1.1.2<% if (typescript) { %>",
     "@glint/environment-ember-loose": "^1.4.0",
+    "@glint/environment-ember-template-imports": "^1.4.0",
     "@glint/template": "^1.4.0",
     "@tsconfig/ember": "^3.0.8",
     "@types/eslint__js": "^8.42.3",
@@ -77,6 +78,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0<% if (welcome) { %>",
     "ember-welcome-page": "^7.0.2<% } %>",
     "eslint": "^9.12.0",
diff --git a/blueprints/app/files/tsconfig.json b/blueprints/app/files/tsconfig.json
index 9387ba942..d987b0f5a 100644
--- a/blueprints/app/files/tsconfig.json
+++ b/blueprints/app/files/tsconfig.json
@@ -1,5 +1,8 @@
 {
   "extends": "@tsconfig/ember/tsconfig.json",
+  "glint": {
+    "environment": ["ember-loose", "ember-template-imports"]
+  },
   "compilerOptions": {
     // The combination of `baseUrl` with `paths` allows Ember's classic package
     // layout, which is not resolvable with the Node resolution algorithm, to


Test patch:
diff --git a/tests/fixtures/addon/defaults-travis/package.json b/tests/fixtures/addon/defaults-travis/package.json
index 96792112e..115fc7a30 100644
--- a/tests/fixtures/addon/defaults-travis/package.json
+++ b/tests/fixtures/addon/defaults-travis/package.json
@@ -29,7 +29,8 @@
   },
   "dependencies": {
     "ember-cli-babel": "^7.26.6",
-    "ember-cli-htmlbars": "^5.7.1"
+    "ember-cli-htmlbars": "^5.7.1",
+    "ember-template-imports": "^4.1.3"
   },
   "devDependencies": {
     "@babel/eslint-parser": "^7.19.1",
diff --git a/tests/fixtures/addon/defaults/package.json b/tests/fixtures/addon/defaults/package.json
index 11daa2d3d..9561ab7c8 100644
--- a/tests/fixtures/addon/defaults/package.json
+++ b/tests/fixtures/addon/defaults/package.json
@@ -30,7 +30,8 @@
   "dependencies": {
     "@babel/core": "^7.25.2",
     "ember-cli-babel": "^8.2.0",
-    "ember-cli-htmlbars": "^6.3.0"
+    "ember-cli-htmlbars": "^6.3.0",
+    "ember-template-imports": "^4.1.3"
   },
   "devDependencies": {
     "@babel/eslint-parser": "^7.25.1",
diff --git a/tests/fixtures/addon/pnpm/package.json b/tests/fixtures/addon/pnpm/package.json
index 2a5f228e2..7982139f1 100644
--- a/tests/fixtures/addon/pnpm/package.json
+++ b/tests/fixtures/addon/pnpm/package.json
@@ -30,7 +30,8 @@
   "dependencies": {
     "@babel/core": "^7.25.2",
     "ember-cli-babel": "^8.2.0",
-    "ember-cli-htmlbars": "^6.3.0"
+    "ember-cli-htmlbars": "^6.3.0",
+    "ember-template-imports": "^4.1.3"
   },
   "devDependencies": {
     "@babel/eslint-parser": "^7.25.1",
diff --git a/tests/fixtures/addon/typescript/package.json b/tests/fixtures/addon/typescript/package.json
index e03ccef87..3de0dbdb4 100644
--- a/tests/fixtures/addon/typescript/package.json
+++ b/tests/fixtures/addon/typescript/package.json
@@ -48,7 +48,8 @@
   "dependencies": {
     "@babel/core": "^7.25.2",
     "ember-cli-babel": "^8.2.0",
-    "ember-cli-htmlbars": "^6.3.0"
+    "ember-cli-htmlbars": "^6.3.0",
+    "ember-template-imports": "^4.1.3"
   },
   "devDependencies": {
     "@ember/optional-features": "^2.1.0",
@@ -58,6 +59,7 @@
     "@glimmer/component": "^1.1.2",
     "@glimmer/tracking": "^1.1.2",
     "@glint/environment-ember-loose": "^1.4.0",
+    "@glint/environment-ember-template-imports": "^1.4.0",
     "@glint/template": "^1.4.0",
     "@tsconfig/ember": "^3.0.8",
     "@types/eslint__js": "^8.42.3",
diff --git a/tests/fixtures/addon/typescript/tsconfig.json b/tests/fixtures/addon/typescript/tsconfig.json
index b4455bf29..80b7f1c5c 100644
--- a/tests/fixtures/addon/typescript/tsconfig.json
+++ b/tests/fixtures/addon/typescript/tsconfig.json
@@ -1,5 +1,8 @@
 {
   "extends": "@tsconfig/ember/tsconfig.json",
+  "glint": {
+    "environment": ["ember-loose", "ember-template-imports"]
+  },
   "compilerOptions": {
     // The combination of `baseUrl` with `paths` allows Ember's classic package
     // layout, which is not resolvable with the Node resolution algorithm, to
diff --git a/tests/fixtures/addon/yarn/package.json b/tests/fixtures/addon/yarn/package.json
index 52c43e3ce..8c270df1a 100644
--- a/tests/fixtures/addon/yarn/package.json
+++ b/tests/fixtures/addon/yarn/package.json
@@ -30,7 +30,8 @@
   "dependencies": {
     "@babel/core": "^7.25.2",
     "ember-cli-babel": "^8.2.0",
-    "ember-cli-htmlbars": "^6.3.0"
+    "ember-cli-htmlbars": "^6.3.0",
+    "ember-template-imports": "^4.1.3"
   },
   "devDependencies": {
     "@babel/eslint-parser": "^7.25.1",
diff --git a/tests/fixtures/app/defaults/package.json b/tests/fixtures/app/defaults/package.json
index c0d37a627..12e835e98 100644
--- a/tests/fixtures/app/defaults/package.json
+++ b/tests/fixtures/app/defaults/package.json
@@ -54,6 +54,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0",
     "ember-welcome-page": "^7.0.2",
     "eslint": "^9.12.0",
diff --git a/tests/fixtures/app/embroider-no-welcome/package.json b/tests/fixtures/app/embroider-no-welcome/package.json
index 598553aac..669d2d9ce 100644
--- a/tests/fixtures/app/embroider-no-welcome/package.json
+++ b/tests/fixtures/app/embroider-no-welcome/package.json
@@ -55,6 +55,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0",
     "eslint": "^9.12.0",
     "eslint-config-prettier": "^9.1.0",
diff --git a/tests/fixtures/app/embroider-pnpm/package.json b/tests/fixtures/app/embroider-pnpm/package.json
index b9cf3f4aa..2376033fa 100644
--- a/tests/fixtures/app/embroider-pnpm/package.json
+++ b/tests/fixtures/app/embroider-pnpm/package.json
@@ -55,6 +55,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0",
     "ember-welcome-page": "^7.0.2",
     "eslint": "^9.12.0",
diff --git a/tests/fixtures/app/embroider-yarn/package.json b/tests/fixtures/app/embroider-yarn/package.json
index b9da16d79..246adbf73 100644
--- a/tests/fixtures/app/embroider-yarn/package.json
+++ b/tests/fixtures/app/embroider-yarn/package.json
@@ -55,6 +55,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0",
     "ember-welcome-page": "^7.0.2",
     "eslint": "^9.12.0",
diff --git a/tests/fixtures/app/embroider/package.json b/tests/fixtures/app/embroider/package.json
index 484ce0bdd..3ea359fcf 100644
--- a/tests/fixtures/app/embroider/package.json
+++ b/tests/fixtures/app/embroider/package.json
@@ -55,6 +55,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0",
     "ember-welcome-page": "^7.0.2",
     "eslint": "^9.12.0",
diff --git a/tests/fixtures/app/nested-project/actual-project/package.json b/tests/fixtures/app/nested-project/actual-project/package.json
index fc9c0c55f..8888a4738 100644
--- a/tests/fixtures/app/nested-project/actual-project/package.json
+++ b/tests/fixtures/app/nested-project/actual-project/package.json
@@ -50,6 +50,7 @@
     "ember-qunit": "^5.1.4",
     "ember-resolver": "^8.0.2",
     "ember-source": "~3.27.0-beta.3",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^4.0.0",
     "ember-welcome-page": "^5.0.0",
     "eslint": "^8.32.0",
diff --git a/tests/fixtures/app/npm-travis/package.json b/tests/fixtures/app/npm-travis/package.json
index 707efc4c1..60c74579d 100644
--- a/tests/fixtures/app/npm-travis/package.json
+++ b/tests/fixtures/app/npm-travis/package.json
@@ -51,6 +51,7 @@
     "ember-qunit": "^5.1.4",
     "ember-resolver": "^8.0.2",
     "ember-source": "~3.27.2",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^4.0.0",
     "eslint": "^8.32.0",
     "eslint-config-prettier": "^8.3.0",
diff --git a/tests/fixtures/app/npm/package.json b/tests/fixtures/app/npm/package.json
index cef155adc..7ca380206 100644
--- a/tests/fixtures/app/npm/package.json
+++ b/tests/fixtures/app/npm/package.json
@@ -54,6 +54,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0",
     "eslint": "^9.12.0",
     "eslint-config-prettier": "^9.1.0",
diff --git a/tests/fixtures/app/pnpm/package.json b/tests/fixtures/app/pnpm/package.json
index dfbba1912..135ca11ba 100644
--- a/tests/fixtures/app/pnpm/package.json
+++ b/tests/fixtures/app/pnpm/package.json
@@ -54,6 +54,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0",
     "ember-welcome-page": "^7.0.2",
     "eslint": "^9.12.0",
diff --git a/tests/fixtures/app/typescript-embroider/package.json b/tests/fixtures/app/typescript-embroider/package.json
index e490e09af..6b7d7c97f 100644
--- a/tests/fixtures/app/typescript-embroider/package.json
+++ b/tests/fixtures/app/typescript-embroider/package.json
@@ -47,6 +47,7 @@
     "@glimmer/component": "^1.1.2",
     "@glimmer/tracking": "^1.1.2",
     "@glint/environment-ember-loose": "^1.4.0",
+    "@glint/environment-ember-template-imports": "^1.4.0",
     "@glint/template": "^1.4.0",
     "@tsconfig/ember": "^3.0.8",
     "@types/eslint__js": "^8.42.3",
@@ -73,6 +74,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0",
     "ember-welcome-page": "^7.0.2",
     "eslint": "^9.12.0",
diff --git a/tests/fixtures/app/typescript-embroider/tsconfig.json b/tests/fixtures/app/typescript-embroider/tsconfig.json
index e61dd08cc..4a5785db1 100644
--- a/tests/fixtures/app/typescript-embroider/tsconfig.json
+++ b/tests/fixtures/app/typescript-embroider/tsconfig.json
@@ -1,5 +1,8 @@
 {
   "extends": "@tsconfig/ember/tsconfig.json",
+  "glint": {
+    "environment": ["ember-loose", "ember-template-imports"]
+  },
   "compilerOptions": {
     // The combination of `baseUrl` with `paths` allows Ember's classic package
     // layout, which is not resolvable with the Node resolution algorithm, to
diff --git a/tests/fixtures/app/typescript/package.json b/tests/fixtures/app/typescript/package.json
index edefa5a55..46ae133db 100644
--- a/tests/fixtures/app/typescript/package.json
+++ b/tests/fixtures/app/typescript/package.json
@@ -44,6 +44,7 @@
     "@glimmer/component": "^1.1.2",
     "@glimmer/tracking": "^1.1.2",
     "@glint/environment-ember-loose": "^1.4.0",
+    "@glint/environment-ember-template-imports": "^1.4.0",
     "@glint/template": "^1.4.0",
     "@tsconfig/ember": "^3.0.8",
     "@types/eslint__js": "^8.42.3",
@@ -72,6 +73,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0",
     "ember-welcome-page": "^7.0.2",
     "eslint": "^9.12.0",
diff --git a/tests/fixtures/app/typescript/tsconfig.json b/tests/fixtures/app/typescript/tsconfig.json
index e61dd08cc..4a5785db1 100644
--- a/tests/fixtures/app/typescript/tsconfig.json
+++ b/tests/fixtures/app/typescript/tsconfig.json
@@ -1,5 +1,8 @@
 {
   "extends": "@tsconfig/ember/tsconfig.json",
+  "glint": {
+    "environment": ["ember-loose", "ember-template-imports"]
+  },
   "compilerOptions": {
     // The combination of `baseUrl` with `paths` allows Ember's classic package
     // layout, which is not resolvable with the Node resolution algorithm, to
diff --git a/tests/fixtures/app/with-blueprint-override-lint-fail/package.json b/tests/fixtures/app/with-blueprint-override-lint-fail/package.json
index a41be1db3..02e618cf7 100644
--- a/tests/fixtures/app/with-blueprint-override-lint-fail/package.json
+++ b/tests/fixtures/app/with-blueprint-override-lint-fail/package.json
@@ -50,6 +50,7 @@
     "ember-qunit": "^5.1.2",
     "ember-resolver": "^8.0.2",
     "ember-source": "~3.26.0-beta.2",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^4.0.0",
     "ember-welcome-page": "^5.0.0",
     "eslint": "^8.32.0",
diff --git a/tests/fixtures/app/yarn-travis/package.json b/tests/fixtures/app/yarn-travis/package.json
index a93470a2d..4db25ca7a 100644
--- a/tests/fixtures/app/yarn-travis/package.json
+++ b/tests/fixtures/app/yarn-travis/package.json
@@ -51,6 +51,7 @@
     "ember-qunit": "^5.1.4",
     "ember-resolver": "^8.0.2",
     "ember-source": "~3.27.2",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^4.0.0",
     "ember-welcome-page": "^4.0.0",
     "eslint": "^8.32.0",
diff --git a/tests/fixtures/app/yarn/package.json b/tests/fixtures/app/yarn/package.json
index f2e26cbcb..89a745f84 100644
--- a/tests/fixtures/app/yarn/package.json
+++ b/tests/fixtures/app/yarn/package.json
@@ -54,6 +54,7 @@
     "ember-qunit": "^8.1.0",
     "ember-resolver": "^13.0.2",
     "ember-source": "~6.0.0-beta.1",
+    "ember-template-imports": "^4.1.3",
     "ember-template-lint": "^6.0.0",
     "ember-welcome-page": "^7.0.2",
     "eslint": "^9.12.0",