@@ -283,22 +283,27 @@ export class PluginsService implements IPluginsService {
283283 _ . keys ( packageJsonContent . devDependencies )
284284 ) ;
285285
286- const notInstalledDependencies = allDependencies . map ( dep => {
287- try {
288- this . $logger . trace ( `Checking if ${ dep } is installed...` ) ;
289- require . resolve ( `${ dep } /package.json` , {
290- paths : [ projectData . projectDir ]
291- } )
292-
293- // return false if the dependency is installed - we'll filter out boolean values
294- // and end up with an array of dep names that are not installed if we end up
295- // inside the catch block.
296- return false ;
297- } catch ( err ) {
298- this . $logger . trace ( `Error while checking if ${ dep } is installed. Error is: ` , err )
299- return dep ;
300- }
301- } ) . filter ( Boolean ) ;
286+ const notInstalledDependencies = allDependencies
287+ . map ( ( dep ) => {
288+ try {
289+ this . $logger . trace ( `Checking if ${ dep } is installed...` ) ;
290+ require . resolve ( `${ dep } /package.json` , {
291+ paths : [ projectData . projectDir ] ,
292+ } ) ;
293+
294+ // return false if the dependency is installed - we'll filter out boolean values
295+ // and end up with an array of dep names that are not installed if we end up
296+ // inside the catch block.
297+ return false ;
298+ } catch ( err ) {
299+ this . $logger . trace (
300+ `Error while checking if ${ dep } is installed. Error is: ` ,
301+ err
302+ ) ;
303+ return dep ;
304+ }
305+ } )
306+ . filter ( Boolean ) ;
302307
303308 if ( this . $options . force || notInstalledDependencies . length ) {
304309 this . $logger . trace (
@@ -342,7 +347,8 @@ export class PluginsService implements IPluginsService {
342347 dependencies =
343348 dependencies ||
344349 this . $nodeModulesDependenciesBuilder . getProductionDependencies (
345- projectData . projectDir , projectData . ignoredDependencies
350+ projectData . projectDir ,
351+ projectData . ignoredDependencies
346352 ) ;
347353
348354 if ( _ . isEmpty ( dependencies ) ) {
@@ -357,10 +363,14 @@ export class PluginsService implements IPluginsService {
357363 projectData . projectDir ,
358364 platform
359365 ) ;
360- const pluginData = productionPlugins . map ( ( plugin ) =>
361- this . convertToPluginData ( plugin , projectData . projectDir )
362- ) ;
363- return pluginData ;
366+ return productionPlugins
367+ . map ( ( plugin ) => this . convertToPluginData ( plugin , projectData . projectDir ) )
368+ . filter ( ( item , idx , self ) => {
369+ // Filter out duplicates to speed up build times by not building the same dependency
370+ // multiple times. One possible downside is that if there are different versions
371+ // of the same native dependency only the first one in the array will be built
372+ return self . findIndex ( ( p ) => p . name === item . name ) === idx ;
373+ } ) ;
364374 }
365375
366376 public getDependenciesFromPackageJson (
0 commit comments