Skip to content

Commit

Permalink
add warn pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
smouillour committed Oct 12, 2023
1 parent 03d2f1a commit de2c965
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions fork/dynamic-cdn-webpack-plugin/src/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand All @@ -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;
}, []);
Expand Down

0 comments on commit de2c965

Please sign in to comment.