fix: deps check error when dev add production plugin (#3848)

* fix: deps check error when dev add production plugin

* fix: bug
This commit is contained in:
jack zhang 2024-04-01 14:18:00 +08:00 committed by GitHub
parent 28ca702ab9
commit 88b317f937
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 5 deletions

View File

@ -505,15 +505,24 @@ export interface DepCompatible {
}
export async function getCompatible(packageName: string) {
let externalVersion: Record<string, string>;
if (!process.env.IS_DEV_CMD) {
const hasSrc = fs.existsSync(path.join(getPackageDir(packageName), 'src'));
let hasError = false;
if (hasSrc) {
try {
externalVersion = await getExternalVersionFromSource(packageName);
} catch (error) {
console.log('getExternalVersionFromSource error:', error);
hasError = true;
}
}
if (hasError || !hasSrc) {
const res = await getExternalVersionFromDistFile(packageName);
if (!res) {
return false;
} else {
externalVersion = res;
}
} else {
externalVersion = await getExternalVersionFromSource(packageName);
}
return Object.keys(externalVersion).reduce<DepCompatible[]>((result, packageName) => {

View File

@ -0,0 +1,2 @@
/node_modules
/src