Registry / web-framework / babel-plugin-ember-template-compilation

babel-plugin-ember-template-compilation

JSON →
library4.0.0jsnpmunverified

Babel plugin implementing Ember's low-level template compilation API. Current stable version is 4.0.0 (released 2026-01-13). Maintained by the Ember core team. It handles compiling Ember handlebars templates into JavaScript functions during Babel transpilation. Key differentiator: it is the official, modern way to precompile Ember templates in build pipelines (Embroider, classic builds). Breaking changes: v3.0.0 converted to ESM-only and dropped Node <18; v4.0.0 avoids leaking real filename paths in output. Release cadence: major/minor every few months.

npm install babel-plugin-ember-template-compilation
INSTALL
IMPORT
SIG · BABEL-PLUGIN-EMBER
B
babel-plugin-ember-template-compilation
web-frameworkjavascriptv4.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin)
module.exports = require('babel-plugin-ember-template-compilation');
import plugin from 'babel-plugin-ember-template-compilation';
v3+ is ESM-only, use import or require with babel config.
outputFormat
{ plugins: [ ['babel-plugin-ember-template-compilation', { outputFormat: 'wire' }] ] }
{ plugins: [ ['babel-plugin-ember-template-compilation', { format: 'wire' }] ] }
outputFormat is the correct option key, not format.
targetFormat
{ plugins: [ ['babel-plugin-ember-template-compilation', { targetFormat: 'wire' }] ] }
{ plugins: [ ['babel-plugin-ember-template-compilation', { target: 'wire' }] ] }
targetFormat (introduced in v3 alpha) is distinct from outputFormat; see docs.

Configures Babel to compile Ember template strings (via hbs) using the wire format and @glimmer/compiler.

// babel.config.js module.exports = function (api) { api.cache(true); return { presets: [ ['@babel/preset-env', { targets: { node: 'current' } }] ], plugins: [ ['babel-plugin-ember-template-compilation', { outputFormat: 'wire', compilerPath: require.resolve('@glimmer/compiler') }] ] }; }; // In your component: import { hbs } from 'ember-template-imports'; const template = hbs` <h1>Hello {{name}}</h1> `; export default class MyComponent { name = 'World'; }
Debug
Known issues
breakingv3.0.0 converted to ESM-only; dropping CommonJS and Node < 18 support.
fix
Update to Node >=18, and ensure your Babel config or bundler handles ESM. If using require(), switch to import.
affects: >=3.0.0
breakingv4.0.0 avoids leaking real filename paths in output due to moduleName.
fix
If you relied on the real path in moduleName, configure it explicitly using the 'moduleName' option in the plugin.
affects: >=4.0.0
gotchaThe 'outputFormat' option is required if not using auto-detection. Common mistake: using 'format' instead.
fix
Use option key 'outputFormat' (not 'format'). Valid values: 'wire', 'hbs', 'hbs-loose'.
affects: >=2.0.0
deprecatedThe 'targetFormat' option was introduced in v3 alpha and may replace 'outputFormat' in future.
fix
Prefer 'targetFormat' when using v3+. Check documentation for mapping.
affects: >=3.0.0-alpha
breakingv2.4.1 fixes incorrect 'this' binding when there's a TypeScript 'this' arg in scope.
fix
Upgrade to >=2.4.1 to get correct this binding.
affects: <2.4.1
Errors
Common errors & fixes
Error: Cannot find module '@glimmer/compiler'
The plugin depends on @glimmer/compiler, which is not installed or not in node_modules.
fix
Run: npm install --save-dev @glimmer/compiler
TypeError: babel-plugin-ember-template-compilation is not a function
Using a CommonJS require in an ESM-only version (v3+).
fix
Use import plugin from 'babel-plugin-ember-template-compilation' or update Babel config to use import.
The 'moduleName' option must be a string or false, got undefined.
Missing the moduleName option in plugin config when using certain outputFormat.
fix
Add moduleName: false if you don't want filenames, or set it to a string.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
@babel/corerequiredRequired as a peer dependency for the Babel plugin interface.
@glimmer/syntaxrequiredUsed internally for parsing and transforming Handlebars templates.
@glimmer/compilerrequiredUsed internally for compiling templates to bytecode.
Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources
babel-plugin-ember-template-compilation — npm install babel-plugin-ember-template-compilation · libregistry