Commit f9d203f
fix: resolve bare package imports against the "." exports subpath (#1276)
`resolveExportPath('')` — the call made for bare package imports like
`import x from 'foo'` — used to blindly prepend './' to the lookup key,
turning '' into './'. That never matched the '.' key stored in the
resolved exports map, so the export lookup silently returned zero paths.
In practice the bug was masked for packages that also declared a `main`
field, because `resolveSourceFile` falls back to `mainPaths` when the
exports lookup returns nothing and `exportPath === ''`. Packages that
only declared `exports` (no `main`) would not resolve their bare entry
point and the parser would fail to walk their dependency graph.
Normalize both '' and '.' to '.' so the lookup matches the canonical
'.' subpath key used by both the string-shorthand `exports: "./foo.js"`
form and the object form `exports: { ".": "./foo.js" }`. Subpath imports
(either bare 'sub' or './sub') continue to work unchanged.
Tests added:
- Plain string exports resolved via bare import
- Object exports with '.' key resolved via bare import
- Single-level conditional exports under '.' resolved via bare import
- Explicit '.' exportPath accepted
- Regression guard for non-bare subpath imports
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 8213010 commit f9d203f
File tree
2 files changed
+88
-3
lines changed- packages/cli/src/services/check-parser/package-files
- __tests__
2 files changed
+88
-3
lines changedLines changed: 75 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
281 | 356 | | |
282 | 357 | | |
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
90 | 100 | | |
91 | 101 | | |
92 | 102 | | |
| |||
0 commit comments