import path = require ( 'path' ) ; import dotProp = require ( 'dot-prop' ) ; import { CoreProperties as PackageManifest } from '@schemastore/package' ; function rebaseInput ( rootDir , filePath ) { return path . join ( rootDir , path . basename ( filePath ) ) ; } param { PackageManifest } pkg return { String } export function getInput ( pkg , cwd ) { if ( ! pkg . main ) { const location = path . relative ( '.' , path . join ( cwd , 'package.json' ) ) ; throw new TypeError ( `required field 'main' missing in ${ location }` ) ; } const rootDir = dotProp . get ( pkg , 'rollup.rootDir' , 'src' ) ; const input = dotProp . get ( pkg , 'rollup.input' , rebaseInput ( rootDir , pkg . main ) ) ; return path . resolve ( cwd , input ) ; }