* fix(pnp): make sure that the package locator is...
... fetched with a trailing slash
I could not get P'n'P working on a project using `critical`[1] and
traced it down to a lookup of a package locator without a trailing
slash.
A `require('resolve').sync('fg-loadcss')` from `inline-critical`[2]
would fail to resolve as the `locatorsByLocations` lookup in `.pnp.js`
would be using a key without a trailing slash, i.e.:
```
"../../.cache/yarn/v4/npm-inline-critical-4.0.7-3ffba6a869f39215c8bb00ed2dd6b872e7f98adc/node_modules/inline-critical"
```
`findPackageLocator` is invoked with `location` parameter (notice no
trailing slash):
```
location = "/home/zregvart/.cache/yarn/v4/npm-inline-critical-4.0.7-3ffba6a869f39215c8bb00ed2dd6b872e7f98adc/node_modules/inline-critical"
```
from `resolveToUnqualified` with parameters:
```
request = "fg-loadcss/package.json"
issuer = "/home/zregvart/.cache/yarn/v4/npm-inline-critical-4.0.7-3ffba6a869f39215c8bb00ed2dd6b872e7f98adc/node_modules/inline-critical"
```
All starting from `loadNodeModulesSync` in `resolve`'s `sync.js`[3]
that ends up having `absoluteStart` without the trailing slash.
Not sure if this is the most correct way of fixing this issue, by just
ensuring that the trailing slash needed for the lookup is added if
missing.
All tests from `yarn test` and from `packages/pkg-tests`
`yarn jest yarn.test.js` pass, so it seems like a start.
This is how to reproduce:
package.json:
```json
{
"name": "require-failure",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"install": "node --require ./.pnp.js index.js"
},
"devDependencies": {
"critical": "^1.3.4"
},
"installConfig": {
"pnp": true
}
}
```
index.js:
```javascript
require('critical').generate({
inline: true,
html: '<!DOCTYPE html><html><head><link rel="stylesheet" href="site.css"></head><body><h1>Hello</h1></body></html>'
});
```
site.css:
```css
h1 { font-weight: bold; }
```
Not sure how to create a package test from that example (sorry).
[1] https://github.com/addyosmani/critical
[2] 340db21f6a/index.js (L32)
[3] 254bb4029d/lib/sync.js (L52)
* Update CHANGELOG.md
Fast, reliable, and secure dependency management.
Fast: Yarn caches every package it has downloaded, so it never needs to download the same package again. It also does almost everything concurrently to maximize resource utilization. This means even faster installs.
Reliable: Using a detailed but concise lockfile format and a deterministic algorithm for install operations, Yarn is able to guarantee that any installation that works on one system will work exactly the same on another system.
Secure: Yarn uses checksums to verify the integrity of every installed package before its code is executed.
Features
- Offline Mode. If you've installed a package before, then you can install it again without an internet connection.
- Deterministic. The same dependencies will be installed in the same exact way on any machine, regardless of installation order.
- Network Performance. Yarn efficiently queues requests and avoids request waterfalls in order to maximize network utilization.
- Network Resilience. A single request that fails will not cause the entire installation to fail. Requests are automatically retried upon failure.
- Flat Mode. Yarn resolves mismatched versions of dependencies to a single version to avoid creating duplicates.
- More emojis. 🐈
Installing Yarn
Read the Installation Guide on our website for detailed instructions on how to install Yarn.
Using Yarn
Read the Usage Guide on our website for detailed instructions on how to use Yarn.
Contributing to Yarn
Contributions are always welcome, no matter how large or small. Substantial feature requests should be proposed as an RFC. Before contributing, please read the code of conduct.
See Contributing.
Prior art
Yarn wouldn't exist if it wasn't for excellent prior art. Yarn has been inspired by the following projects:
Credits
Thanks to Sam Holmes for donating the npm package name!