@@ -183,37 +183,48 @@ function isNotRelative (file) {
183183 return isRelative ( file ) && file [ 0 ] !== '.'
184184}
185185
186- function parse ( opts ) {
186+ function resolveDefaultEntriesPaths ( opts ) {
187187 const pkgPath = opts . path
188+ const pkgDir = path . dirname ( pkgPath )
188189 const pkg = opts . package
189- const extensions = opts . extensions
190190
191- const deps = { }
192- const seen = [ ]
193- const core = [ ]
194- const mainPath = path . resolve ( pkg . main || path . join ( path . dirname ( pkgPath ) , 'index.js' ) )
191+ const mainPath = path . resolve ( pkg . main || path . join ( pkgDir , 'index.js' ) )
195192
196193 let paths = [ ]
197194
198- if ( ! opts . noDefaultEntries && fs . existsSync ( mainPath ) ) paths . push ( mainPath )
195+ // Add the path of the main file
196+ if ( fs . existsSync ( mainPath ) ) paths . push ( mainPath )
199197
200- if ( ! opts . noDefaultEntries && pkg . bin ) {
198+ // Add the path of binaries
199+ if ( pkg . bin ) {
201200 if ( typeof pkg . bin === 'string' ) {
202- paths . push ( path . resolve ( path . join ( path . dirname ( pkgPath ) , pkg . bin ) ) )
203201 } else {
204202 Object . keys ( pkg . bin ) . forEach ( cmdName => {
205203 const cmd = pkg . bin [ cmdName ]
206- paths . push ( path . resolve ( path . join ( path . dirname ( pkgPath ) , cmd ) ) )
204+ paths . push ( path . resolve ( path . join ( pkgDir , cmd ) ) )
207205 } )
208206 }
209207 }
210208
211- // pass in custom additional entries e.g. ['./test.js']
212- if ( opts . entries ) {
213- paths = paths . concat (
214- resolveGlobbedPath ( opts . entries , path . dirname ( pkgPath ) )
215- )
216- }
209+ return paths
210+ }
211+
212+ function resolvePaths ( opts ) {
213+ return [
214+ ...( ! opts . noDefaultEntries ? resolveDefaultEntriesPaths ( opts ) : [ ] ) ,
215+ ...( opts . entries ? resolveGlobbedPath ( opts . entries , path . dirname ( opts . path ) ) : [ ] )
216+ ]
217+ }
218+
219+ function parse ( opts ) {
220+ const pkg = opts . package
221+ const extensions = opts . extensions
222+
223+ const deps = { }
224+ const seen = [ ]
225+ const core = [ ]
226+
227+ const paths = resolvePaths ( opts )
217228
218229 debug ( 'entry paths' , paths )
219230
0 commit comments