diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/runtime-template-compiler-implicit-test.ts b/packages/@ember/-internals/glimmer/tests/integration/components/runtime-template-compiler-implicit-test.ts index 3aaf14d29f4..78a5852ed16 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/runtime-template-compiler-implicit-test.ts +++ b/packages/@ember/-internals/glimmer/tests/integration/components/runtime-template-compiler-implicit-test.ts @@ -7,6 +7,28 @@ import { fn } from '@ember/helper'; moduleFor( 'Strict Mode - Runtime Template Compiler (implicit)', class extends RenderingTestCase { + async '@test can immediately render a runtime-compiled template'() { + class State { + get component() { + return template(`hello there`); + } + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + let state = new State(); + + await this.renderComponentModule(() => { + return template('', { + eval() { + return eval(arguments[0]); + }, + }); + }); + + this.assertHTML('hello there'); + this.assertStableRerender(); + } + async '@test Can use a component in scope'() { await this.renderComponentModule(() => { let Foo = template('Hello, world!', { diff --git a/packages/@ember/template-compiler/lib/template.ts b/packages/@ember/template-compiler/lib/template.ts index 7140656fffd..51f77b71f8f 100644 --- a/packages/@ember/template-compiler/lib/template.ts +++ b/packages/@ember/template-compiler/lib/template.ts @@ -242,12 +242,10 @@ export function template( const normalizedOptions = compileOptions(options); const component = normalizedOptions.component ?? templateOnly(); - queueMicrotask(() => { - const source = glimmerPrecompile(templateString, normalizedOptions); - const template = templateFactory(evaluate(`(${source})`) as SerializedTemplateWithLazyBlock); + const source = glimmerPrecompile(templateString, normalizedOptions); + const template = templateFactory(evaluate(`(${source})`) as SerializedTemplateWithLazyBlock); - setComponentTemplate(template, component); - }); + setComponentTemplate(template, component); return component; }