@@ -29,7 +29,7 @@ export class TnsModulesCopy {
29
29
let matchPattern = this . $options . release ? "**/*.ts" : "**/*.d.ts" ;
30
30
allFiles . filter ( file => minimatch ( file , matchPattern , { nocase : true } ) ) . map ( file => this . $fs . deleteFile ( file ) ) ;
31
31
32
- shelljs . rm ( "-rf" , path . join ( tnsCoreModulesResourcePath , "node_modules" ) ) ;
32
+ shelljs . rm ( "-rf" , path . join ( tnsCoreModulesResourcePath , constants . NODE_MODULES_FOLDER_NAME ) ) ;
33
33
}
34
34
}
35
35
}
@@ -51,6 +51,25 @@ export class TnsModulesCopy {
51
51
52
52
// remove platform-specific files (processed separately by plugin services)
53
53
shelljs . rm ( "-rf" , path . join ( targetPackageDir , "platforms" ) ) ;
54
+
55
+ this . removeNonProductionDependencies ( dependency , targetPackageDir ) ;
56
+ }
57
+ }
58
+
59
+ private removeNonProductionDependencies ( dependency : IDependencyData , targetPackageDir : string ) : void {
60
+ const packageJsonFilePath = path . join ( dependency . directory , constants . PACKAGE_JSON_FILE_NAME ) ;
61
+ if ( ! this . $fs . exists ( packageJsonFilePath ) ) {
62
+ return ;
63
+ }
64
+
65
+ const packageJsonContent = this . $fs . readJson ( packageJsonFilePath ) ;
66
+ const productionDependencies = packageJsonContent . dependencies ;
67
+
68
+ const dependenciesFolder = path . join ( targetPackageDir , constants . NODE_MODULES_FOLDER_NAME ) ;
69
+ if ( this . $fs . exists ( dependenciesFolder ) ) {
70
+ const dependencies = this . $fs . readDirectory ( dependenciesFolder ) ;
71
+ dependencies . filter ( dir => ! ! productionDependencies || ! productionDependencies . hasOwnProperty ( dir ) )
72
+ . forEach ( dir => shelljs . rm ( "-rf" , path . join ( dependenciesFolder , dir ) ) ) ;
54
73
}
55
74
}
56
75
}
0 commit comments