From de2c9651362ddae9902b4e2a8bca6516a72cc7e7 Mon Sep 17 00:00:00 2001 From: smouillour Date: Thu, 12 Oct 2023 11:41:13 +0200 Subject: [PATCH] add warn pnpm --- fork/dynamic-cdn-webpack-plugin/src/find.js | 23 +++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fork/dynamic-cdn-webpack-plugin/src/find.js b/fork/dynamic-cdn-webpack-plugin/src/find.js index c2a93405b08..f8d937ba951 100644 --- a/fork/dynamic-cdn-webpack-plugin/src/find.js +++ b/fork/dynamic-cdn-webpack-plugin/src/find.js @@ -21,6 +21,7 @@ function findPackage(info) { return semver.satisfies(version, range); }); } +let warnPNPMonce = true; function findPackagesFromScopeFolder(scope, name, scopeFolderPath) { const isWantedScope = scopeFolderPath.endsWith(`${path.sep}${scope}`); @@ -34,12 +35,22 @@ function findPackagesFromScopeFolder(scope, name, scopeFolderPath) { // just add the path to the found list return accu.concat(subFolderPath); } - // TODO NOT COMPATIBLE WITH PNPM - // the scope or package name is not the one we look for - // if there is a nested node modules folder, we dive into it for the search - const nestedNodeModulesPath = path.join(subFolderPath, 'node_modules'); - if (fs.existsSync(nestedNodeModulesPath)) { - return accu.concat(findPackagesFromNonScopeFolder(scope, name, nestedNodeModulesPath, [])); + if ( + !(process.env.npm_config_user_agent && process.env.npm_config_user_agent.includes('pnpm')) + ) { + // TODO NOT COMPATIBLE WITH PNPM + // the scope or package name is not the one we look for + // if there is a nested node modules folder, we dive into it for the search + const nestedNodeModulesPath = path.join(subFolderPath, 'node_modules'); + if (fs.existsSync(nestedNodeModulesPath)) { + return accu.concat( + findPackagesFromNonScopeFolder(scope, name, nestedNodeModulesPath, []), + ); + } + } else if (warnPNPMonce) { + warnPNPMonce = false; + console.warn('Executed with PNPM: Not compatible with deep search of dependencies!!'); + console.warn('Executed with PNPM: Certainly due to circular dependencies'); } return accu; }, []);