ember-cli-babel provides extensive configuration options through two main configuration keys: ember-cli-babel for addon-specific settings and babel for direct Babel configuration.
Options specific to ember-cli-babel's behavior and integration with Ember CLI.
interface EmberCLIBabelOptions {
/** Include external Babel helpers to reduce bundle size (app-level only) */
includeExternalHelpers?: boolean;
/** Compile ES6 modules to AMD format */
compileModules?: boolean;
/** Disable debug macro processing for @ember/debug */
disableDebugTooling?: boolean;
/** Disable @babel/preset-env entirely */
disablePresetEnv?: boolean;
/** Disable Ember modules API polyfill */
disableEmberModulesAPIPolyfill?: boolean;
/** Disable EmberData packages polyfill */
disableEmberDataPackagesPolyfill?: boolean;
/** Disable decorator and class property transforms */
disableDecoratorTransforms?: boolean;
/** Enable TypeScript transpilation */
enableTypeScriptTransform?: boolean;
/** File extensions to process (default: ['js'] or ['js', 'ts']) */
extensions?: string[];
/** Use external babel.config.js instead of auto-generated config */
useBabelConfig?: boolean;
/** Annotation for broccoli-babel-transpiler */
annotation?: string;
/** Throw unless parallelizable for broccoli-babel-transpiler */
throwUnlessParallelizable?: boolean;
}Usage Examples:
// ember-cli-build.js - App configuration
let app = new EmberApp(defaults, {
'ember-cli-babel': {
includeExternalHelpers: true,
enableTypeScriptTransform: true,
disableDebugTooling: false,
extensions: ['js', 'ts', 'gjs']
}
});
// index.js - Addon configuration
module.exports = {
options: {
'ember-cli-babel': {
compileModules: false,
disableDecoratorTransforms: true
}
}
};
// index.js - Engine configuration
module.exports = EngineAddon.extend({
'ember-cli-babel': {
enableTypeScriptTransform: true
}
});Direct Babel configuration options passed through to @babel/preset-env and Babel core.
interface BabelOptions {
/** Enable spec compliance mode */
spec?: boolean;
/** Enable loose mode transformations for smaller/faster output */
loose?: boolean;
/** Enable debug logging */
debug?: boolean;
/** Force include specific transforms regardless of targets */
include?: string[];
/** Exclude specific transforms */
exclude?: string[];
/** Configure built-in polyfill usage */
useBuiltIns?: boolean | 'entry' | 'usage';
/** Source map generation */
sourceMaps?: boolean | 'inline' | 'both';
/** Generator options for code output */
generatorOpts?: object;
/** Additional Babel plugins */
plugins?: BabelPlugin[];
/** Additional post-transform plugins */
postTransformPlugins?: BabelPlugin[];
}Usage Examples:
// ember-cli-build.js - Babel configuration
let app = new EmberApp(defaults, {
babel: {
sourceMaps: 'inline',
loose: true,
exclude: ['transform-regenerator'],
plugins: [
require.resolve('babel-plugin-transform-object-rest-spread'),
[require.resolve('babel-plugin-transform-runtime'), {
version: '7.12.0',
regenerator: false
}]
]
}
});Configuration for including external Babel helpers to reduce bundle size.
interface ExternalHelpersConfig {
/** Enable external helpers (app-level only) */
includeExternalHelpers: boolean;
}External helpers are only configurable at the app level and will reduce bundle size by sharing common Babel helper functions across modules.
Automatic Detection: ember-cli-babel automatically detects when helpers would be beneficial based on:
@ember-decorators/babel-transformsUsage Examples:
// Explicitly enable external helpers
let app = new EmberApp(defaults, {
'ember-cli-babel': {
includeExternalHelpers: true
}
});
// Explicitly disable external helpers
let app = new EmberApp(defaults, {
'ember-cli-babel': {
includeExternalHelpers: false
}
});Configuration for TypeScript transpilation support.
interface TypeScriptConfig {
/** Enable TypeScript transpilation */
enableTypeScriptTransform: boolean;
/** File extensions to process when TypeScript is enabled */
extensions?: string[];
}TypeScript transpilation is automatically enabled when ember-cli-typescript >= 4.0 is detected. It can also be manually enabled.
Usage Examples:
// Manual TypeScript enabling in app
let app = new EmberApp(defaults, {
'ember-cli-babel': {
enableTypeScriptTransform: true,
extensions: ['js', 'ts', 'gts']
}
});
// Manual TypeScript enabling in addon
module.exports = {
options: {
'ember-cli-babel': {
enableTypeScriptTransform: true
}
}
};Configuration for debug macro processing and production stripping.
interface DebugToolingConfig {
/** Disable debug macro processing entirely */
disableDebugTooling: boolean;
}When enabled (default), debug tooling provides:
@ember/debug statements in production@glimmer/env DEBUG flagUsage Examples:
// Disable debug tooling
let app = new EmberApp(defaults, {
'ember-cli-babel': {
disableDebugTooling: true
}
});Configuration for ES6 module compilation to AMD format.
interface ModuleCompilationConfig {
/** Compile ES6 modules to AMD (default: auto-detected) */
compileModules: boolean;
}Module compilation is automatically enabled for Ember CLI versions > 2.12.0 unless explicitly disabled.
Usage Examples:
// Disable module compilation
let app = new EmberApp(defaults, {
'ember-cli-babel': {
compileModules: false
}
});
// Force enable module compilation for older Ember CLI
let app = new EmberApp(defaults, {
'ember-cli-babel': {
compileModules: true
}
});Configuration for using external babel.config.js files instead of auto-generated configuration.
interface ExternalBabelConfig {
/** Use external babel.config.js file */
useBabelConfig: boolean;
}When enabled, ember-cli-babel will look for and use a babel.config.js file in the project root instead of generating its own configuration.
Usage Examples:
// ember-cli-build.js - Enable external Babel config
let app = new EmberApp(defaults, {
'ember-cli-babel': {
useBabelConfig: true
}
});
// babel.config.js - External configuration
const { buildEmberPlugins } = require('ember-cli-babel');
module.exports = function(api) {
api.cache(true);
return {
presets: [
[require.resolve('@babel/preset-env'), {
targets: require('./config/targets')
}]
],
plugins: [
...buildEmberPlugins(__dirname),
require.resolve('my-custom-plugin')
]
};
};Configuration flows through the Ember CLI addon hierarchy:
ember-cli-build.js) - Highest priorityindex.js options) - Addon-specific overridesApp-only Options:
includeExternalHelpers - Can only be configured at app levelInherited Options: All other options are inherited through the addon tree, with more specific configurations overriding general ones.
Some configuration options behave differently based on the build environment:
Production Environment (EMBER_ENV=production):
Development Environment (EMBER_ENV=development):
Test Environment (EMBER_ENV=test):