From 82b5b1d3e2b5acc7432e311ca551d368a3cdc4b1 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 12 Dec 2023 14:29:45 -0500 Subject: [PATCH] [BUGFIX beta] internal templates should be strictMode As of https://github.com/emberjs/ember.js/pull/20587, the modules published under `dist/packages` act more like normal addon code, in that their templates are published as calls to `precompileTemplate` rather than wire format. But that makes this the first time that Embroider is seeing these templates, and because they are in loose mode and use the dynamic component helper they are un-analyzable. This PR: - switches them to strict mode - fixes the declared types for `precompileTemplate`, which were a lie before. `scope` is allowed in non-strict mode. `scope` is optional even in strict mode. - fixes a spelling error in a recently-introduced internal method, because I noticed it and it annoyed me. --- .../-internals/glimmer/lib/templates/empty.ts | 1 + .../-internals/glimmer/lib/templates/input.ts | 9 +++++++- .../glimmer/lib/templates/link-to.ts | 10 +++++++- .../glimmer/lib/templates/outlet.ts | 8 ++++++- .../-internals/glimmer/lib/templates/root.ts | 1 + .../glimmer/lib/templates/textarea.ts | 10 +++++++- packages/@ember/-internals/package.json | 1 + packages/@ember/template-compilation/index.ts | 23 +++++++------------ packages/@ember/test/index.ts | 2 +- packages/ember-testing/index.ts | 4 ++-- pnpm-lock.yaml | 5 +++- type-tests/@ember/template-compilation.ts | 6 ----- 12 files changed, 51 insertions(+), 29 deletions(-) diff --git a/packages/@ember/-internals/glimmer/lib/templates/empty.ts b/packages/@ember/-internals/glimmer/lib/templates/empty.ts index a8a8cb394b3..f5665d5f8b0 100644 --- a/packages/@ember/-internals/glimmer/lib/templates/empty.ts +++ b/packages/@ember/-internals/glimmer/lib/templates/empty.ts @@ -1,4 +1,5 @@ import { precompileTemplate } from '@ember/template-compilation'; export default precompileTemplate('', { moduleName: 'packages/@ember/-internals/glimmer/lib/templates/empty.hbs', + strictMode: true, }); diff --git a/packages/@ember/-internals/glimmer/lib/templates/input.ts b/packages/@ember/-internals/glimmer/lib/templates/input.ts index 2620336bcab..295bb8d2a69 100644 --- a/packages/@ember/-internals/glimmer/lib/templates/input.ts +++ b/packages/@ember/-internals/glimmer/lib/templates/input.ts @@ -1,4 +1,5 @@ import { precompileTemplate } from '@ember/template-compilation'; +import { on } from '@ember/modifier'; export default precompileTemplate( ``, - { moduleName: 'packages/@ember/-internals/glimmer/lib/templates/input.hbs' } + { + moduleName: 'packages/@ember/-internals/glimmer/lib/templates/input.hbs', + strictMode: true, + scope() { + return { on }; + }, + } ); diff --git a/packages/@ember/-internals/glimmer/lib/templates/link-to.ts b/packages/@ember/-internals/glimmer/lib/templates/link-to.ts index 40eb24cddf4..811ef33d63b 100644 --- a/packages/@ember/-internals/glimmer/lib/templates/link-to.ts +++ b/packages/@ember/-internals/glimmer/lib/templates/link-to.ts @@ -1,4 +1,6 @@ import { precompileTemplate } from '@ember/template-compilation'; +import { on } from '@ember/modifier'; + export default precompileTemplate( `{{yield}}`, - { moduleName: 'packages/@ember/-internals/glimmer/lib/templates/link-to.hbs' } + { + moduleName: 'packages/@ember/-internals/glimmer/lib/templates/link-to.hbs', + strictMode: true, + scope() { + return { on }; + }, + } ); diff --git a/packages/@ember/-internals/glimmer/lib/templates/outlet.ts b/packages/@ember/-internals/glimmer/lib/templates/outlet.ts index a186b6229b7..803be28628f 100644 --- a/packages/@ember/-internals/glimmer/lib/templates/outlet.ts +++ b/packages/@ember/-internals/glimmer/lib/templates/outlet.ts @@ -1,4 +1,10 @@ import { precompileTemplate } from '@ember/template-compilation'; -export default precompileTemplate(`{{component (-outlet)}}`, { +import { outletHelper } from '../syntax/outlet'; + +export default precompileTemplate(`{{component (outletHelper)}}`, { moduleName: 'packages/@ember/-internals/glimmer/lib/templates/outlet.hbs', + strictMode: true, + scope() { + return { outletHelper }; + }, }); diff --git a/packages/@ember/-internals/glimmer/lib/templates/root.ts b/packages/@ember/-internals/glimmer/lib/templates/root.ts index f83924a3faa..bb4736d9214 100644 --- a/packages/@ember/-internals/glimmer/lib/templates/root.ts +++ b/packages/@ember/-internals/glimmer/lib/templates/root.ts @@ -1,4 +1,5 @@ import { precompileTemplate } from '@ember/template-compilation'; export default precompileTemplate(`{{component this}}`, { moduleName: 'packages/@ember/-internals/glimmer/lib/templates/root.hbs', + strictMode: true, }); diff --git a/packages/@ember/-internals/glimmer/lib/templates/textarea.ts b/packages/@ember/-internals/glimmer/lib/templates/textarea.ts index 9a9e32d0fd4..1b4bdfc2d9b 100644 --- a/packages/@ember/-internals/glimmer/lib/templates/textarea.ts +++ b/packages/@ember/-internals/glimmer/lib/templates/textarea.ts @@ -1,4 +1,6 @@ import { precompileTemplate } from '@ember/template-compilation'; +import { on } from '@ember/modifier'; + export default precompileTemplate( `