From 5442a39e0a3d9992ea088579e801e2726d91682a Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Sat, 17 Feb 2018 16:07:43 -0800 Subject: [PATCH] add a no-op optimization --- index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b7bdf9a8..45298b12 100644 --- a/index.js +++ b/index.js @@ -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`); }, @@ -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; + } };