{"record":{"id":"e4e019f1defced0a","repo":"emberjs/ember.js","slug":"cannot-call-compile-with-only-the-template-compi","errorCode":null,"errorMessage":"Cannot call `compile` with only the template compiler loaded. Please load `ember.debug.js` or `ember.prod.js` prior to calling `compile`.","messagePattern":"Cannot call `compile` with only the template compiler loaded\\. Please load `ember\\.debug\\.js` or `ember\\.prod\\.js` prior to calling `compile`\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/ember-template-compiler/lib/system/compile.ts","lineNumber":22,"sourceCode":"import type { EmberPrecompileOptions } from '../types';\nimport precompile from './precompile';\nimport type { SerializedTemplateWithLazyBlock, TemplateFactory } from '@glimmer/interfaces';\nimport { template } from '@ember/-internals/glimmer';\n\n/**\n  Uses HTMLBars `compile` function to process a string into a compiled template.\n  This is not present in production builds.\n  @private\n  @method compile\n  @param {String} templateString This is the string to be compiled by HTMLBars.\n  @param {Object} options This is an options hash to augment the compiler options.\n*/\nexport default function compile(\n  templateString: string,\n  options: Partial<EmberPrecompileOptions> = {}\n): TemplateFactory {\n  if (!template) {\n    throw new Error(\n      'Cannot call `compile` with only the template compiler loaded. Please load `ember.debug.js` or `ember.prod.js` prior to calling `compile`.'\n    );\n  }\n\n  return template(evaluate(precompile(templateString, options)));\n}\n\nfunction evaluate(precompiled: string): SerializedTemplateWithLazyBlock {\n  return new Function(`return ${precompiled}`)();\n}\n","sourceCodeStart":4,"sourceCodeEnd":33,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/ember-template-compiler/lib/system/compile.ts#L4-L33","documentation":"Ember's compile() needs the runtime template function loaded from the full Ember build (ember.debug.js / ember.prod.js). If the standalone template compiler package is loaded without it, the `template` binding is absent, so compile throws instead of producing a broken TemplateFactory.","triggerScenarios":"Calling compile() in an environment where only @ember/-template-compiler / the precompiler bundle is loaded and the main ember bundle defining `template` was never loaded or loaded after compile ran.","commonSituations":"Browser test setups importing only the template compiler; build-tool misconfiguration dropping ember.debug.js/prod.js; executing compile() at module top level before Ember finishes loading; using compile in Node with only the compiler installed.","solutions":["Load ember.debug.js (dev) or ember.prod.js (prod) before any compile() call","Reorder imports so Ember's runtime loads before the compiler is invoked","Avoid runtime compile() in production — precompile templates at build time","If compiling in Node/tests, ensure the full Ember environment (or @glimmer runtime + template factory) is available"],"exampleFix":"// before\nimport compile from 'ember-template-compiler/system/compile';\nconst factory = compile('<h1>Hi</h1>');\n// after\nimport 'ember'; // loads ember.debug.js / ember.prod.js first\nimport compile from 'ember-template-compiler/system/compile';\nconst factory = compile('<h1>Hi</h1>');","handlingStrategy":"try-catch","validationCode":"import { _templateFactory } from 'ember'; // ensure runtime loaded\nif (typeof window?.DS === 'undefined' && typeof require('ember') === 'undefined') { throw new Error('Load ember.debug.js/prod.js before compile()'); }","typeGuard":null,"tryCatchPattern":"import compile from 'ember-template-compiler/system/compile';\ntry { factory = compile(src); } catch (e) { if (e.message.includes('only the template compiler loaded')) { await import('ember').then(() => compile(src)); } else { throw e; } }","preventionTips":["Precompile templates at build time; avoid runtime compile()","Ensure the full Ember bundle loads before any compile call","Check import order in test harnesses and shims","Never invoke compile at module top level before app boot"],"tags":["ember","module-loading","template-compiler","build"],"backgroundTag":"missing-runtime-dependency","analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}