Skip to content
Snippets Groups Projects
Commit 9d17dc7e authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

getPackagePath: handle the current package not being installed

In case we want to get the package path of the current package, but it
isn't in node_modules (as is the case with yarn2) we need to find it
ourselves.

In case the package.json in the current dir has the same name we just use
it as a base. This is after rollup lookup failed, so this is just a fallback.
parent 1bb97438
No related branches found
No related tags found
Loading
Pipeline #23662 failed
......@@ -39,8 +39,14 @@ export async function getPackagePath(packageName, assetPath) {
const packageInfo = r.getPackageInfoForId(id);
packageRoot = packageInfo.root;
} else {
// Non JS packages
packageRoot = path.dirname(require.resolve(packageName + '/package.json'));
let current = require.resolve('./package.json');
if (require(current).name === packageName) {
// current package
packageRoot = path.dirname(current);
} else {
// Non JS packages
packageRoot = path.dirname(require.resolve(packageName + '/package.json'));
}
}
return path.relative(process.cwd(), path.join(packageRoot, assetPath));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment