static void processTranspile ( AbstractCompiler compiler , Node combinedRoot , FeatureSet featureSet , Callback ... callbacks ) { if ( compiler . getOptions ( ) . needsTranspilationFrom ( featureSet ) ) { FeatureSet languageOutFeatures = compiler . getOptions ( ) . getOutputFeatureSet ( ) ; for ( Node singleRoot : combinedRoot . children ( ) ) { // Only run the transpilation if this file has features not in the compiler's target output // language. For example, if this file is purely ES6 and the output language is ES6, don't // run any transpilation passes on it. // TODO(lharker): We could save time by being more selective about what files we transpile. // e.g. if a file has async functions but not `**`, don't run `**` transpilation on it. // Right now we know what features were in a file at parse time, but not what features were // added to that file by other transpilation passes. if ( doesScriptHaveUnsupportedFeatures ( singleRoot , languageOutFeatures ) ) { for ( Callback callback : callbacks ) { singleRoot . putBooleanProp ( Node . TRANSPILED , true ) ; NodeTraversal . traverse ( compiler , singleRoot , callback ) ; } } } } }
Process transpilations if the input language needs transpilation from certain features on any JS file that has features not present in the compiler s output language mode .