Registry /
web-framework / babel-plugin-ember-modules-api-polyfill
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
babel-plugin-ember-modules-api-polyfill
✓ module.exports = { plugins: ['babel-plugin-ember-modules-api-polyfill'] };
✗ module.exports = { plugins: ['ember-modules-api-polyfill'] };
This plugin is configured by its string name in Babel configurations (e.g., `.babelrc`, `babel.config.js`). Omission of the `babel-plugin-` prefix is a common configuration mistake.
babel-plugin-ember-modules-api-polyfill (with options)
✓ module.exports = { plugins: [['babel-plugin-ember-modules-api-polyfill', { useEmberModule: true }]] };
✗ module.exports = { plugins: ['babel-plugin-ember-modules-api-polyfill', { useEmberModule: true }] };
When passing options to a Babel plugin, the plugin name string and its options object must be nested within an additional array. Failing to do so will result in Babel misinterpreting the configuration.
This quickstart demonstrates how to configure `babel-plugin-ember-modules-api-polyfill` in a `babel.config.js` file and provides an example Ember component utilizing modern module imports that the plugin will transpile to legacy global API access.
// babel.config.js
module.exports = {
plugins: [
['babel-plugin-ember-modules-api-polyfill', {
// Recommended option for Ember 3.27+ to avoid global window.Ember deprecation
useEmberModule: true
}]
]
};
// src/my-component.js (Example input code)
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class MyComponent extends Component {
@service auth;
@tracked count = 0;
@action
increment() {
this.count++;
console.log(`Current count: ${this.count}`);
}
constructor() {
super(...arguments);
console.log('Auth service injected:', this.auth);
}
}
// To apply the transformation with Babel CLI (assuming babel-cli is installed):
// npx babel src/my-component.js --out-file dist/my-component.js --config-file babel.config.js
// The output in dist/my-component.js would contain code using Ember.Component, Ember.inject.service, etc.
Debug
Known issues
breakingThe plugin's configuration option `blacklist` was renamed to `ignore` in v3.0.0. Using `blacklist` in versions 3.0.0 or newer will cause configuration errors.fixUpdate your Babel configuration to replace `blacklist` with `ignore` for this plugin's options.
affects: >=3.0.0
gotchaFor Ember 3.27+ applications, it is highly recommended to enable the `useEmberModule` option in the plugin's configuration to mitigate `window.Ember` deprecation warnings.fixAdd `{ useEmberModule: true }` as an option to the plugin configuration in your Babel setup. affects: >=3.3.0
gotchaThis plugin is designed to operate within the Ember CLI build system via `ember-cli-babel`. Ensure your project's `ember-cli-babel` dependency is version `6.6.0` or higher to guarantee proper integration and expected behavior.fixUpgrade `ember-cli-babel` to `^6.6.0` or a newer compatible version in your `package.json`.
affects: N/A (check `ember-cli-babel` version)
Errors
Common errors & fixes
TypeError: Invalid option 'blacklist' passed to 'babel-plugin-ember-modules-api-polyfill'
Using the deprecated `blacklist` configuration option with plugin versions 3.0.0 or later.
fixChange the `blacklist` option to `ignore` in your `babel-plugin-ember-modules-api-polyfill` configuration.
TypeError: Cannot read properties of undefined (reading 'container')
A bug affecting certain code coverage configurations when using plugin versions prior to 3.2.2.
fixUpgrade `babel-plugin-ember-modules-api-polyfill` to version `3.2.2` or newer to resolve this bug.
Syntax Error: Decorators must be applied to an identifier, not an alias.
Incorrect transpilation of aliased decorator identifiers within decorated methods in plugin versions prior to 3.2.1.
fixUpgrade `babel-plugin-ember-modules-api-polyfill` to version `3.2.1` or newer to correctly handle aliased decorators.
Audit
Dependencies
ember-cli-babelrequiredRequired for Ember CLI to detect and apply this plugin in its build pipeline; ensures proper integration and functionality.