Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixes errors in the PnP spec
  • Loading branch information
arcanis committed Aug 9, 2022
commit 5eccabc8c5aa91fb3fc9946d03257f9860031362
18 changes: 12 additions & 6 deletions packages/gatsby/content/advanced/pnp-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,23 @@ import {JsonDoc} from 'react-json-doc';

8. Let `referenceOrAlias` be the entry from `parentPkg.packageDependencies` referenced by `ident`

9. If `referenceOrAlias` is **undefined**, then
9. If `referenceOrAlias` is **null** or **undefined**, then

1. If `manifest.enableTopLevelFallback` is **true**, then

1. If `parentLocator` **isn't** in `manifest.fallbackExclusionList`, then

1. Set `referenceOrAlias` to **RESOLVE_VIA_FALLBACK**(`manifest`, `ident`)
1. Let `fallback` be **RESOLVE_VIA_FALLBACK**(`manifest`, `ident`)

2. If `fallback` is neither **null** nor **undefined**

1. Set `referenceOrAlias` to `fallback`

10. If `referenceOrAlias` is still **undefined**, then

1. Throw a resolution error

11. If `referenceOrAlias` is **null**, then
11. If `referenceOrAlias` is still **null**, then

1. Note: It means that `parentPkg` has an unfulfilled peer dependency on `ident`

Expand Down Expand Up @@ -205,13 +209,15 @@ Note: The algorithm described here is quite inefficient. You should make sure to

3. Let `relativeUrl` be the relative path between `manifest` and `moduleUrl`

1. Note: Make sure it always starts with a `./` or `../`
1. Note: The relative path must not start with `./`; trim it if needed

4. If `relativeUrl` matches `manifest.ignorePatternData`, then

1. Return **null**

5. For each `referenceMap` value in `manifest.packageRegistryData`
5. Let `relativeUrlWithDot` be `relativeUrl` prefixed with `./` or `../` as necessary
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI relativeUrlWithDot is never used. I'm assuming it's supposed to be used instead of relativeUrl below.


6. For each `referenceMap` value in `manifest.packageRegistryData`

1. For each `registryPkg` value in `referenceMap`

Expand All @@ -227,7 +233,7 @@ Note: The algorithm described here is quite inefficient. You should make sure to

6. Return `bestLocator`

### RESOLVE_VIA_FALLBACK(`manifest`, `specifier`)
### RESOLVE_VIA_FALLBACK(`manifest`, `ident`)

1. Let `topLevelPkg` be **GET_PACKAGE**(`manifest`, {**null**, **null**})

Expand Down
24 changes: 11 additions & 13 deletions packages/gatsby/static/configuration/pnp.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,19 @@
"description": "A map of locators that all packages are allowed to access, regardless whether they list them in their dependencies or not.",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"pattern": "^(?:@([^/]+?)/)?([^/]+?)$",
"examples": ["@app/name"]
},
"reference": {
"type": "string",
"examples": ["workspace:."]
}
}
"type": "array",
"prefixItems": [{
"type": "string",
"pattern": "^(?:@([^/]+?)/)?([^/]+?)$",
"examples": ["@app/name"]
}, {
"type": "string",
"foldStyle": false,
"examples": ["workspace:."]
}]
},
"exampleItems": [
{"name": "@app/monorepo", "reference": "workspace:."}
["@app/monorepo", "workspace:."]
]
},
"fallbackExclusionList": {
Expand Down
2 changes: 1 addition & 1 deletion packages/yarnpkg-pnp/tests/testExpectations.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[null, [
[null, {
"packageLocation": "./",
"packageDependencies": [],
"packageDependencies": [["test", "npm:1.0.0"]],
"linkType": "SOFT"
}]
]],
Expand Down