import { API , FileInfo , Options } from 'jscodeshift' ; export function loadableRequire ( file , api , options ) { const j = api . jscodeshift ; const root = j ( file . source ) ; const printOptions = options . printOptions || { quote : 'single' , trailingComma : false , lineTerminator : '\n' } ; root . find ( j . CallExpression ) . filter ( ( path ) => { if ( path . node . type === 'CallExpression' ) { if ( path . node . callee . type === 'Identifier' && path . node . callee . name === 'loadable' ) { return true ; } } } ) . forEach ( ( path ) => { const file = path . node . arguments [ 0 ] . body . arguments [ 0 ] . value ; j ( path ) . replaceWith ( j . callExpression ( j . identifier ( 'require' ) , [ j . stringLiteral ( file ) ] ) ) ; } ) ; return root . toSource ( printOptions ) ; } export const parser = 'tsx' ; export default loadableRequire ;