From cb637c5962bca852035743f5e72b1da406b6d0b2 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Tue, 22 Aug 2017 19:37:48 +0300 Subject: [PATCH] Fix prepare of scoped plugins In case a plugin depends on a scoped package, for example `@angular/core`, trying to use the plugin from local path with npm 5 will fail. The recommended approach is to declare the scoped package (`@angular/core`) as a devDependency of the plugin. After that, declare both the plugin and the scoped package as dependencies of your project. In case the plugin is installed from local directory, npm 5 creates symlink in node_modules. This means that all files inside `/node_modules` will be visible for CLI, including the dev dependencies. During project preparation CLI copies `node_modules` from the project to `/platforms/...` directory. We have a specific logic to process only dependencies of each package, i.e. we should remove `@angular/core` from the plugin's node_modules direcotry. However, the logic is not working correctly as instead of using the name `@angular/core` it's been trying to remove `core` only. Fix getting names of the dependencies, so we'll be able to remove the scoped packages as well. --- lib/tools/node-modules/node-modules-dest-copy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tools/node-modules/node-modules-dest-copy.ts b/lib/tools/node-modules/node-modules-dest-copy.ts index f80b0f175b..f3f534c373 100644 --- a/lib/tools/node-modules/node-modules-dest-copy.ts +++ b/lib/tools/node-modules/node-modules-dest-copy.ts @@ -65,7 +65,9 @@ export class TnsModulesCopy { const dependencies = _.flatten(this.$fs.readDirectory(dependenciesFolder) .map(dir => { if (_.startsWith(dir, "@")) { - return this.$fs.readDirectory(path.join(dependenciesFolder, dir)); + const pathToDir = path.join(dependenciesFolder, dir); + const contents = this.$fs.readDirectory(pathToDir); + return _.map(contents, subDir => `${dir}/${subDir}`); } return dir;