Map < String , String > processJsonInputs ( Iterable < CompilerInput > inputsToProcess ) { RewriteJsonToModule rewriteJson = new RewriteJsonToModule ( this ) ; for ( CompilerInput input : inputsToProcess ) { if ( ! input . getSourceFile ( ) . getOriginalPath ( ) . endsWith ( ".json" ) ) { continue ; } input . setCompiler ( this ) ; try { // JSON objects need wrapped in parens to parse properly input . getSourceFile ( ) . setCode ( "(" + input . getSourceFile ( ) . getCode ( ) + ")" ) ; } catch ( IOException e ) { continue ; } Node root = checkNotNull ( input . getAstRoot ( this ) ) ; input . setJsModuleType ( CompilerInput . ModuleType . JSON ) ; rewriteJson . process ( null , root ) ; } return rewriteJson . getPackageJsonMainEntries ( ) ; }
Transforms JSON files to a module export that closure compiler can process and keeps track of any main entries in package . json files .