Skip to content

Commit

Permalink
add a no-op optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed Feb 18, 2018
1 parent 4b68bef commit 5442a39
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ module.exports = {
let description = `000${++count}`.slice(-3);
let postDebugTree = this._debugTree(inputTree, `${description}:input`);

let BabelTranspiler = require('broccoli-babel-transpiler');
let output = new BabelTranspiler(postDebugTree, this.buildBabelOptions(config));
let options = this.buildBabelOptions(config);
let output;
if (this._shouldDoNothing(options)) {
output = postDebugTree;
} else {
let BabelTranspiler = require('broccoli-babel-transpiler');
output = new BabelTranspiler(postDebugTree, options);
}

return this._debugTree(output, `${description}:output`);
},
Expand Down Expand Up @@ -378,4 +384,9 @@ module.exports = {

return checker.exists();
},

// detect if running babel would do nothing... and do nothing instead
_shouldDoNothing(options) {
return !options.sourceMaps && !options.plugins.length;
}
};

0 comments on commit 5442a39

Please sign in to comment.