Repository navigation
Commit e1f4d61
Resolver: Gracefully reject illegal browser-spec redirects of bare specifier -> absolute path
Summary:
While doing some refactoring here I noticed some nonsensical handling of the case where a browser-spec `package.json` tries to redirect a bare specifier to an absolute path, eg:
```
// /project/package.json
{
"browser": {
"foo-pkg": "/var/foo"
}
}
```
This currently causes the resolver to redirect to `/project/var/foo` - *joining* the absolute path onto the end of the origin-relative path.
This is surely never the desired behaviour, and is outside the [`browser` field spec](https://github.com/defunctzombie/package-browser-field-spec#replace-specific-files---advanced).
Rather than "fix" this and support something new in an increasingly outdated spec (`browser` redirects have been effectively replaced by `exports`/`imports` maps), here we just replace what was broken with a graceful, actionable rejection.
Although this changes observable resolver behaviour, I think it's safe to treat this as non-breaking because the previous behaviour was so unexpected.
```
- **[Fix]**: Resolver: Gracefully reject bare->absolute redirects rather than failing on a spurious path
```
Reviewed By: huntie
Differential Revision: D102568988
fbshipit-source-id: 5bf8d6c3f5a26e0b3ea2fd3f49a3dd9fa41136631 parent 9341463 commit e1f4d61
2 files changed
Lines changed: 43 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
486 | 511 | | |
487 | 512 | | |
488 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
139 | | - | |
| 138 | + | |
140 | 139 | | |
141 | 140 | | |
142 | 141 | | |
| |||
151 | 150 | | |
152 | 151 | | |
153 | 152 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | 153 | | |
158 | 154 | | |
159 | 155 | | |
160 | 156 | | |
161 | 157 | | |
162 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
163 | 175 | | |
164 | 176 | | |
165 | 177 | | |
| |||
0 commit comments