import * as ts from 'typescript' ; const transformerProgram = ( ) => { const transformerFactory = context => { return sourceFile => { const visitor = ( node ) : ts . Node => { if ( ts . isImportDeclaration ( node ) && ts . isStringLiteral ( node . moduleSpecifier ) ) { const pkgEntry = require . resolve ( `${ node . moduleSpecifier . text }` ) ; const innerProgram = ts . createProgram ( [ pkgEntry ] , { allowJs : true , } ) ; console . log ( innerProgram . getSourceFile ( pkgEntry ) . getText ( ) ) ; return node ; } return ts . visitEachChild ( node , visitor , context ) ; } ; return ts . visitNode ( sourceFile , visitor ) ; } ; } ; return transformerFactory ; } ; export default transformerProgram ;