diff --git a/CHANGELOG.md b/CHANGELOG.md index dd9a3fa247..c941e3ef8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa [#6912](https://github.com/yarnpkg/yarn/pull/6912) - [**Billy Vong**](https://github.com/billyvg) +- Fixes an issue where `resolve` would forward an incomplete basedir to the PnP hook + + [#6882](https://github.com/yarnpkg/yarn/pull/6882) - [**Zoran Regvart**](https://github.com/zregvart) + ## 1.13.0 - Implements a new `package.json` field: `peerDependenciesMeta` diff --git a/src/util/generate-pnp-map-api.tpl.js b/src/util/generate-pnp-map-api.tpl.js index a703bcb9b7..835b6f85f1 100644 --- a/src/util/generate-pnp-map-api.tpl.js +++ b/src/util/generate-pnp-map-api.tpl.js @@ -773,6 +773,10 @@ exports.setupCompatibilityLayer = () => { // Extract the name of the package being requested (1=full name, 2=scope name, 3=local name) const parts = request.match(/^((?:(@[^\/]+)\/)?([^\/]+))/); + // make sure that basedir ends with a slash + if (basedir.charAt(basedir.length - 1) !== '/') { + basedir = path.join(basedir, '/'); + } // This is guaranteed to return the path to the "package.json" file from the given package const manifestPath = exports.resolveToUnqualified(`${parts[1]}/package.json`, basedir);