@@ -29,7 +29,7 @@ export class TnsModulesCopy {
2929 let matchPattern = this . $options . release ? "**/*.ts" : "**/*.d.ts" ;
3030 allFiles . filter ( file => minimatch ( file , matchPattern , { nocase : true } ) ) . map ( file => this . $fs . deleteFile ( file ) ) ;
3131
32- shelljs . rm ( "-rf" , path . join ( tnsCoreModulesResourcePath , "node_modules" ) ) ;
32+ shelljs . rm ( "-rf" , path . join ( tnsCoreModulesResourcePath , constants . NODE_MODULES_FOLDER_NAME ) ) ;
3333 }
3434 }
3535 }
@@ -51,6 +51,25 @@ export class TnsModulesCopy {
5151
5252 // remove platform-specific files (processed separately by plugin services)
5353 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 ) ) ) ;
5473 }
5574 }
5675}
0 commit comments