@@ -283,22 +283,27 @@ export class PluginsService implements IPluginsService {
283
283
_ . keys ( packageJsonContent . devDependencies )
284
284
) ;
285
285
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 ) ;
302
307
303
308
if ( this . $options . force || notInstalledDependencies . length ) {
304
309
this . $logger . trace (
@@ -342,7 +347,8 @@ export class PluginsService implements IPluginsService {
342
347
dependencies =
343
348
dependencies ||
344
349
this . $nodeModulesDependenciesBuilder . getProductionDependencies (
345
- projectData . projectDir , projectData . ignoredDependencies
350
+ projectData . projectDir ,
351
+ projectData . ignoredDependencies
346
352
) ;
347
353
348
354
if ( _ . isEmpty ( dependencies ) ) {
@@ -357,10 +363,14 @@ export class PluginsService implements IPluginsService {
357
363
projectData . projectDir ,
358
364
platform
359
365
) ;
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
+ } ) ;
364
374
}
365
375
366
376
public getDependenciesFromPackageJson (
0 commit comments