ember-cli-babel
Advanced tools
Comparing version 5.1.10 to 5.2.0
176
index.js
/* jshint node: true */ | ||
'use strict'; | ||
var checker = require('ember-cli-version-checker'); | ||
var VersionChecker = require('ember-cli-version-checker'); | ||
var clone = require('clone'); | ||
@@ -11,5 +11,12 @@ var path = require('path'); | ||
name: 'ember-cli-babel', | ||
configKey: 'ember-cli-babel', | ||
shouldSetupRegistryInIncluded: function() { | ||
return !checker.isAbove(this, '0.2.0'); | ||
init: function() { | ||
this._super.init && this._super.init.apply(this, arguments); | ||
var checker = new VersionChecker(this); | ||
var dep = checker.for('ember-cli', 'npm'); | ||
this._shouldSetupRegistryInIncluded = !dep.satisfies('>=0.2.0'); | ||
this._shouldShowBabelDeprecations = !dep.lt('2.11.0-beta.2'); | ||
}, | ||
@@ -24,3 +31,3 @@ | ||
toTree: function(tree) { | ||
return require('broccoli-babel-transpiler')(tree, getBabelOptions(addon)); | ||
return require('broccoli-babel-transpiler')(tree, addon._getBabelOptions()); | ||
} | ||
@@ -31,4 +38,23 @@ }); | ||
shouldIncludePolyfill: function() { | ||
var options = getAddonOptions(this); | ||
return options.includePolyfill === true; | ||
var addonOptions = this._getAddonOptions(); | ||
var babelOptions = addonOptions.babel; | ||
var customOptions = addonOptions['ember-cli-babel']; | ||
if (this._shouldShowBabelDeprecations && !this._polyfillDeprecationPrinted && | ||
babelOptions && 'includePolyfill' in babelOptions) { | ||
this._polyfillDeprecationPrinted = true; | ||
// we can use writeDeprecateLine() here because the warning will only be shown on newer Ember CLIs | ||
this.ui.writeDeprecateLine( | ||
'Putting the "includePolyfill" option in "babel" is deprecated, please put it in "ember-cli-babel" instead.'); | ||
} | ||
if (customOptions && 'includePolyfill' in customOptions) { | ||
return customOptions.includePolyfill === true; | ||
} else if (babelOptions && 'includePolyfill' in babelOptions) { | ||
return babelOptions.includePolyfill === true; | ||
} else { | ||
return false; | ||
} | ||
}, | ||
@@ -63,3 +89,3 @@ | ||
if (this.shouldSetupRegistryInIncluded()) { | ||
if (this._shouldSetupRegistryInIncluded) { | ||
this.setupPreprocessorRegistry('parent', app.registry); | ||
@@ -71,72 +97,98 @@ } | ||
} | ||
} | ||
}; | ||
}, | ||
function getAddonOptions(addonContext) { | ||
var baseOptions = (addonContext.parent && addonContext.parent.options) || (addonContext.app && addonContext.app.options); | ||
return baseOptions && baseOptions.babel || {}; | ||
} | ||
_getAddonOptions: function() { | ||
return (this.parent && this.parent.options) || (this.app && this.app.options) || {}; | ||
}, | ||
function getBabelOptions(addonContext) { | ||
var options = clone(getAddonOptions(addonContext)); | ||
var ui = addonContext.ui; | ||
_shouldCompileModules: function(addonOptions) { | ||
var babelOptions = addonOptions.babel; | ||
var customOptions = addonOptions['ember-cli-babel']; | ||
// pass a console object that wraps the addon's `UI` object | ||
options.console = { | ||
log: function(message) { | ||
// fallback needed for support of ember-cli < 2.2.0 | ||
if (ui.writeInfoLine) { | ||
ui.writeInfoLine(message); | ||
} else { | ||
ui.writeLine(message, 'INFO'); | ||
} | ||
}, | ||
if (this._shouldShowBabelDeprecations && !this._modulesDeprecationPrinted && | ||
babelOptions && 'compileModules' in babelOptions) { | ||
warn: function(message) { | ||
// fallback needed for support of ember-cli < 2.2.0 | ||
if (ui.writeWarnLine) { | ||
ui.writeWarnLine(message); | ||
} else { | ||
ui.writeLine(message, 'WARN'); | ||
} | ||
}, | ||
this._modulesDeprecationPrinted = true; | ||
error: function(message) { | ||
// fallback needed for support of ember-cli < 2.2.0 | ||
if (ui.writeError) { | ||
ui.writeError(message); | ||
} else { | ||
ui.writeLine(message, 'ERROR'); | ||
} | ||
// we can use writeDeprecateLine() here because the warning will only be shown on newer Ember CLIs | ||
this.ui.writeDeprecateLine( | ||
'Putting the "compileModules" option in "babel" is deprecated, please put it in "ember-cli-babel" instead.'); | ||
} | ||
}; | ||
// Ensure modules aren't compiled unless explicitly set to compile | ||
options.blacklist = options.blacklist || ['es6.modules']; | ||
if (customOptions && 'compileModules' in customOptions) { | ||
return customOptions.compileModules === true; | ||
} else if (babelOptions && 'compileModules' in babelOptions) { | ||
return babelOptions.compileModules === true; | ||
} else { | ||
return false; | ||
} | ||
}, | ||
// do not enable non-standard transforms | ||
if (!('nonStandard' in options)) { | ||
options.nonStandard = false; | ||
} | ||
_getBabelOptions: function() { | ||
var addonOptions = this._getAddonOptions(); | ||
var options = clone(addonOptions.babel || {}); | ||
// Don't include the `includePolyfill` flag, since Babel doesn't care | ||
delete options.includePolyfill; | ||
var compileModules = this._shouldCompileModules(addonOptions); | ||
if (options.compileModules === true) { | ||
if (options.blacklist.indexOf('es6.modules') >= 0) { | ||
options.blacklist.splice(options.blacklist.indexOf('es6.modules'), 1); | ||
var ui = this.ui; | ||
// pass a console object that wraps the addon's `UI` object | ||
options.console = { | ||
log: function(message) { | ||
// fallback needed for support of ember-cli < 2.2.0 | ||
if (ui.writeInfoLine) { | ||
ui.writeInfoLine(message); | ||
} else { | ||
ui.writeLine(message, 'INFO'); | ||
} | ||
}, | ||
warn: function(message) { | ||
// fallback needed for support of ember-cli < 2.2.0 | ||
if (ui.writeWarnLine) { | ||
ui.writeWarnLine(message); | ||
} else { | ||
ui.writeLine(message, 'WARN'); | ||
} | ||
}, | ||
error: function(message) { | ||
// fallback needed for support of ember-cli < 2.2.0 | ||
if (ui.writeError) { | ||
ui.writeError(message); | ||
} else { | ||
ui.writeLine(message, 'ERROR'); | ||
} | ||
} | ||
}; | ||
// Ensure modules aren't compiled unless explicitly set to compile | ||
options.blacklist = options.blacklist || ['es6.modules']; | ||
// do not enable non-standard transforms | ||
if (!('nonStandard' in options)) { | ||
options.nonStandard = false; | ||
} | ||
// Remove custom options from `options` hash that is passed to Babel | ||
delete options.includePolyfill; | ||
delete options.compileModules; | ||
} else { | ||
if (options.blacklist.indexOf('es6.modules') < 0) { | ||
options.blacklist.push('es6.modules'); | ||
var blacklistModulesIndex = options.blacklist.indexOf('es6.modules'); | ||
if (compileModules) { | ||
if (blacklistModulesIndex >= 0) { | ||
options.blacklist.splice(blacklistModulesIndex, 1); | ||
} | ||
} else { | ||
if (blacklistModulesIndex < 0) { | ||
options.blacklist.push('es6.modules'); | ||
} | ||
} | ||
} | ||
// Ember-CLI inserts its own 'use strict' directive | ||
options.blacklist.push('useStrict'); | ||
options.highlightCode = false; | ||
// Ember-CLI inserts its own 'use strict' directive | ||
options.blacklist.push('useStrict'); | ||
options.highlightCode = false; | ||
return options; | ||
} | ||
return options; | ||
}, | ||
}; |
{ | ||
"name": "ember-cli-babel", | ||
"version": "5.1.10", | ||
"version": "5.2.0", | ||
"description": "Ember CLI addon for Babel", | ||
"keywords": [ | ||
"ember-addon", | ||
"babel", | ||
"ember", | ||
"ember-cli", | ||
"transpile", | ||
"transpiler" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/babel/ember-cli-babel/issues" | ||
}, | ||
"license": "MIT", | ||
"author": "Gordon Kristan", | ||
"files": [ | ||
"index.js" | ||
], | ||
"directories": { | ||
@@ -8,2 +25,6 @@ "doc": "doc", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/babel/ember-cli-babel.git" | ||
}, | ||
"scripts": { | ||
@@ -13,23 +34,16 @@ "build": "ember build", | ||
"start": "ember server", | ||
"test": "ember test" | ||
"test": "mocha node-tests && ember test" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/babel/ember-cli-babel.git" | ||
"dependencies": { | ||
"broccoli-babel-transpiler": "^5.6.0", | ||
"broccoli-funnel": "^1.0.0", | ||
"clone": "^2.0.0", | ||
"ember-cli-version-checker": "^1.0.2", | ||
"resolve": "^1.1.2" | ||
}, | ||
"engines": { | ||
"node": ">= 0.10.0" | ||
}, | ||
"author": "Gordon Kristan", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/babel/ember-cli-babel/issues" | ||
}, | ||
"homepage": "https://github.com/babel/ember-cli-babel", | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"console-ui": "^1.0.2", | ||
"core-object": "^2.0.6", | ||
"ember-cli": "^2.6.2", | ||
"ember-cli-app-version": "^1.0.0", | ||
"ember-cli-dependency-checker": "^1.2.0", | ||
@@ -39,18 +53,11 @@ "ember-cli-htmlbars": "^1.0.8", | ||
"ember-cli-inject-live-reload": "^1.3.1", | ||
"ember-cli-qunit": "^2.2.1", | ||
"ember-cli-release": "0.2.9", | ||
"ember-cli-qunit": "^3.0.2", | ||
"ember-export-application-global": "^1.0.3", | ||
"ember-load-initializers": "0.5.1", | ||
"ember-resolver": "2.0.3", | ||
"loader.js": "4.0.11" | ||
"ember-resolver": "^2.1.0", | ||
"loader.js": "4.0.11", | ||
"mocha": "^3.2.0" | ||
}, | ||
"keywords": [ | ||
"ember-addon" | ||
], | ||
"dependencies": { | ||
"broccoli-babel-transpiler": "^5.6.0", | ||
"broccoli-funnel": "^1.0.0", | ||
"clone": "^1.0.2", | ||
"ember-cli-version-checker": "^1.0.2", | ||
"resolve": "^1.1.2" | ||
"engines": { | ||
"node": ">= 0.12" | ||
}, | ||
@@ -57,0 +64,0 @@ "ember-addon": { |
@@ -1,3 +0,7 @@ | ||
# ember-cli-babel [![Build Status](https://travis-ci.org/babel/ember-cli-babel.svg?branch=master)](https://travis-ci.org/babel/ember-cli-babel) | ||
# ember-cli-babel | ||
[![Build Status](https://travis-ci.org/babel/ember-cli-babel.svg?branch=master)](https://travis-ci.org/babel/ember-cli-babel) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/2a6pspve1wrwwyj5/branch/master?svg=true)](https://ci.appveyor.com/project/embercli/ember-cli-babel/branch/master) | ||
This Ember-CLI plugin uses [Babel](https://babeljs.io/) to allow you to use ES6 syntax with your | ||
@@ -27,3 +31,8 @@ Ember-CLI project. | ||
// disable comments | ||
comments: false | ||
comments: false, | ||
// don't transpile arrow and generator functions | ||
blacklist: [ | ||
'es6.arrowFunctions', | ||
'regenerator' | ||
] | ||
} | ||
@@ -30,0 +39,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11632
153
88
14
1
+ Addedclone@2.1.2(transitive)
- Removedclone@1.0.4(transitive)
Updatedclone@^2.0.0