ember-cli-6to5
raw JSON → 3.0.0 verified Fri May 01 auth: no javascript deprecated
An Ember-CLI plugin that uses 6to5 (the precursor to Babel) to transpile ES6 syntax to ES5 for Ember-CLI projects. Version 3.0.0 is the latest stable release. This package is historical and has been superseded by ember-cli-babel. It blacklists the 6to5 module transform by default in favor of Ember-CLI's own ES6 module transpiler. Key differentiator: it was an early integration of 6to5/Babel into Ember-CLI, now obsolete.
Common errors
error Cannot find module '6to5' ↓
cause The package ember-cli-6to5 expects the '6to5' global, but if 6to5 is not installed or is version mismatched, the addon fails.
fix
Ensure 6to5 is installed: 'npm install --save-dev 6to5' or migrate to ember-cli-babel.
error Error: 6to5 options must be an object. Received undefined ↓
cause The configuration in Brocfile.js for the '6to5' key is missing or incorrectly placed.
fix
Configure 6to5 options within the EmberApp constructor as shown: var app = new EmberApp({ '6to5': { /* options */ } });
Warnings
deprecated ember-cli-6to5 is deprecated; use ember-cli-babel instead. ↓
fix Run 'npm uninstall --save-dev ember-cli-6to5 && npm install --save-dev ember-cli-babel' and update Brocfile.js to use 'babel' instead of '6to5'.
gotcha By default, module compilation is disabled; 6to5 does not transpile ES6 modules. Ember-CLI's own module transpiler is used instead. ↓
fix Set compileModules: true in the 6to5 options to enable 6to5 module transpilation.
gotcha The package is named after 6to5, which was renamed to Babel. Ember-cli-6to5 only works with 6to5 v1.x, not with later Babel versions. ↓
fix Migrate to ember-cli-babel for compatibility with modern Babel.
Install
npm install ember-cli-6to5 yarn add ember-cli-6to5 pnpm add ember-cli-6to5 Imports
- default wrong
var Ember = require('ember'); // CJS require, but Ember-CLI uses AMDcorrectimport Ember from 'ember'; // ES6 modules - config wrong
// Attempting to configure in ES module syntaxcorrect// In Brocfile.js: var app = new EmberApp({ '6to5': { comments: false } }); - compileModules wrong
// Omitting compileModules and expecting 6to5 to handle modulescorrect// In Brocfile.js: var app = new EmberApp({ '6to5': { compileModules: true } });
Quickstart
// 1. Install
npm install --save-dev ember-cli-6to5
// 2. Configure in Brocfile.js
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var app = new EmberApp({
'6to5': {
// Disable comments for smaller output
comments: false
}
});
// 3. Use ES6 features in your Ember app
// app/components/my-component.js
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement() {
let message = `Hello from ES6!`;
console.log(message);
}
});
module.exports = app.toTree();