Skip to content

Commit

Permalink
Upgraded Broccoli Babel Plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
adambullmer committed Jul 9, 2017
1 parent c263640 commit 56f5098
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 37 deletions.
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
machine:
node:
version: 5.1.0
version: 6.1.0

dependencies:
override:
Expand Down
52 changes: 19 additions & 33 deletions lib/angular-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const Funnel = require('broccoli-funnel'),
uglifyJs = require('broccoli-uglify-js'),
imagemin = require('broccoli-imagemin'),
fingerprint = require('broccoli-asset-rev'),
amdNameResolver = require('amd-name-resolver').moduleResolve,
amdLoader = require('broccoli-amd-loader'),
Babel = require('broccoli-babel-transpiler'),
unitTest = require('broccoli-karma-plugin'),
Expand Down Expand Up @@ -126,13 +125,7 @@ export default config;

let config = writeFile('/config/environment.js', file);

config = new Babel(config, {
moduleIds: true,
modules: 'amdStrict',
resolveModuleSource: amdNameResolver,
sourceRoot: 'config',
sourceMap: this.isProduction ? false : 'inline'
});
config = babel(config, { sourceRoot: 'config' });

return config;
};
Expand Down Expand Up @@ -325,12 +318,6 @@ AngularApp.prototype.processVendorStyles = function () {
return vendorStyles;
};

function render (errors) {
return errors.map(
error => `${error.line}:${error.column} - ${error.message} (${error.ruleId})`
).join('\n');
}

AngularApp.prototype.runLinter = function (appScriptsTree, appStylesTree) {
const lintScripts = eslint(appScriptsTree, {
annotation: 'ESLint: Lint App Scripts',
Expand Down Expand Up @@ -367,10 +354,7 @@ describe("ESLint | ${escape(relativePath)}", function () {
};

AngularApp.prototype.runTests = function (appScriptsTree, addonsScriptsTree, vendorScriptsTree, lintingResults) {
const tests = new Babel(this.appTestsTree(), {
moduleIds: true,
sourceRoot: 'app'
}),
const tests = babel(this.appTestsTree(), { sourceMap: false }),
karmaConfig = {
singleRun: !this.isServing,
autoWatch: this.isServing,
Expand All @@ -392,7 +376,7 @@ AngularApp.prototype.runTests = function (appScriptsTree, addonsScriptsTree, ven
};

AngularApp.prototype.toTree = function () {
const templates = this.processAngularTemplates(this.templateTree());
const templates = this.processAngularTemplates(this.templateTree());
let html = this.htmlTree(),
vendorScripts = this.processVendorScripts(),
vendorStyles = this.processVendorStyles(),
Expand All @@ -410,20 +394,8 @@ AngularApp.prototype.toTree = function () {

lintingResults = this.runLinter(appScripts, appStyles);

appScripts = new Babel(mergeTrees([appScripts, templates]), {
moduleIds: true,
modules: 'amdStrict',
resolveModuleSource: amdNameResolver,
sourceRoot: 'app',
sourceMap: this.isProduction ? false : 'inline'
});
addonsScripts = new Babel(addonsScripts, {
moduleIds: true,
modules: 'amdStrict',
resolveModuleSource: amdNameResolver,
sourceRoot: 'app',
sourceMap: this.isProduction ? false : 'inline'
});
appScripts = babel(mergeTrees([appScripts, templates]));
addonsScripts = babel(addonsScripts);
appScripts = ngAnnotate(appScripts , { add: true, annotation: 'Ng Annotate: App Scripts' });
addonsScripts = ngAnnotate(addonsScripts , { add: true, annotation: 'Ng Annotate: Addons Scripts' });
vendorScripts = ngAnnotate(vendorScripts , { add: true, annotation: 'Ng Annotate: Vendor Scripts' });
Expand Down Expand Up @@ -550,3 +522,17 @@ AngularApp.prototype.importScript = function (filePath) {
AngularApp.prototype.importStyle = function (filePath) {
this.vendorStyles.push(filePath);
};

function babel (tree, options) {
return new Babel(tree, Object.assign({
moduleIds: true,
sourceRoot: 'app',
sourceMap: this.isProduction ? false : 'inline',
}, options));
}

function render (errors) {
return errors.map(
error => `${error.line}:${error.column} - ${error.message} (${error.ruleId})`
).join('\n');
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-bro-app",
"version": "0.10.2",
"version": "0.11.0",
"description": "Angular broccoli plugin and compilation routine",
"main": "lib/angular-app.js",
"scripts": {
Expand All @@ -25,11 +25,11 @@
},
"homepage": "https://github.com/adambullmer/angular-bro-app#readme",
"dependencies": {
"amd-name-resolver": "0.0.5",
"babel-plugin-transform-es2015-modules-amd": "^6.24.1",
"broccoli-amd-loader": "^0.1.0",
"broccoli-angular-templates-cache": "^1.0.3",
"broccoli-asset-rev": "^2.4.2",
"broccoli-babel-transpiler": "^5.5.0",
"broccoli-babel-transpiler": "^6.1.1",
"broccoli-concat": "^2.2.0",
"broccoli-csslint": "^1.2.0",
"broccoli-file-creator": "^1.1.0",
Expand Down

0 comments on commit 56f5098

Please sign in to comment.