module . exports = ( { types } , { routesPath } ) => { let hasLazyImport = false ; let importName = '' ; return { visitor : { ImportDeclaration ( nodePath , state ) { const isRoutesFile = routesPath === state . filename ; if ( isRoutesFile ) { const { node } = nodePath ; if ( types . isStringLiteral ( node . source , { value : 'ice' } ) ) { node . specifiers . forEach ( ( importSpecifier ) => { if ( importSpecifier . imported && types . isIdentifier ( importSpecifier . imported , { name : 'lazy' } ) ) { hasLazyImport = true ; } if ( types . isImportNamespaceSpecifier ( importSpecifier ) ) { importName = importSpecifier . local && importSpecifier . local . name ; } } ) ; } } } , CallExpression ( nodePath , state ) { const isRoutesFile = routesPath === state . filename ; if ( isRoutesFile ) { const { node } = nodePath ; if ( ( importName && types . isMemberExpression ( node . callee ) && types . isIdentifier ( node . callee . object , { name : importName } ) && types . isIdentifier ( node . callee . property , { name : 'lazy' } ) ) || ( hasLazyImport && ( types . isIdentifier ( node . callee , { name : 'lazy' } ) || types . isIdentifier ( node . callee , { name : 'loadable' } ) ) ) ) { if ( node . arguments . length === 1 ) { node . arguments . push ( types . booleanLiteral ( true ) ) ; } } } } , } , } ; } ;