Repository navigation
Commit 4fcb64a
committed
Resolver: Observe Haste names under unstable_incrementalResolution
## Context
#1949 records what a resolution looks up in the file map, but Haste lookups aren't paths. With `allowHaste`, every bare specifier is looked up by name in the Haste map, and a module of that name appearing later changes the result. So the name needs observing whether or not it was found.
## This change
This adds `haste` to `ResolutionObservations`. It's the bare name, not the platform, because `HastePlugin` falls back from platform to `native` to generic and a change to any of those can change the answer:
https://github.com/react/metro/blob/6dbe97956af0f66f7a1d88014ba0b784a4a4d893/packages/metro-file-map/src/plugins/HastePlugin.js#L194-L213
It's free in the default config, where nothing can have a Haste name and the map is empty. Otherwise the set is created on the first name recorded, since most resolutions are relative imports that never consult Haste. No measurable cost either way.
Invalidating from these needs `HastePlugin` to report which names a change rebound, which is #1953.
## Benchmark
AI-driven, flag on in all columns, 7 interleaved rounds. Everything is within half a percent, inside the run-to-run spread.
| scenario | #1949 | this PR | #1949, Haste enabled | this PR, Haste enabled |
|---|---|---|---|---|
| first build (ms) | 112.4 | 111.8 | 111.2 | 110.6 |
| rebuild, nothing changed (ms) | 7.75 | 7.78 | 7.81 | 7.79 |
| after a source edit, the edited module's dependencies (µs) | 177 | 168 | 170 | 172 |
| after a `package.json` change, re-resolving everything (ms) | 93.2 | 93.2 | 93.6 | 94.1 |
| heap retained after resolving (MB) | 18.8 | 18.8 | | 19.1 |
Changelog: Internal
## Test plan
New tests cover Haste inert, a name found and not found, a deep import, and a relative import.
Benchmark app: the synthetic RN 0.87 app described in #1945 (2.8k-module bundle, 34k-file file map). "Haste enabled" sets `enableGlobalPackages: true`, which gives its first-party packages Haste names.1 parent 33ce98c commit 4fcb64a
4 files changed
Lines changed: 143 additions & 8 deletions
File tree
- packages/metro/src
- DeltaBundler
- __tests__
- node-haste/DependencyGraph
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3313 | 3313 | | |
3314 | 3314 | | |
3315 | 3315 | | |
| 3316 | + | |
3316 | 3317 | | |
3317 | 3318 | | |
3318 | 3319 | | |
| |||
3358 | 3359 | | |
3359 | 3360 | | |
3360 | 3361 | | |
| 3362 | + | |
3361 | 3363 | | |
3362 | 3364 | | |
3363 | 3365 | | |
| |||
3380 | 3382 | | |
3381 | 3383 | | |
3382 | 3384 | | |
| 3385 | + | |
3383 | 3386 | | |
3384 | 3387 | | |
3385 | 3388 | | |
| |||
3405 | 3408 | | |
3406 | 3409 | | |
3407 | 3410 | | |
| 3411 | + | |
3408 | 3412 | | |
3409 | 3413 | | |
3410 | 3414 | | |
| |||
3444 | 3448 | | |
3445 | 3449 | | |
3446 | 3450 | | |
| 3451 | + | |
3447 | 3452 | | |
3448 | 3453 | | |
3449 | 3454 | | |
| |||
3456 | 3461 | | |
3457 | 3462 | | |
3458 | 3463 | | |
| 3464 | + | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
| 3499 | + | |
| 3500 | + | |
| 3501 | + | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
| 3530 | + | |
| 3531 | + | |
| 3532 | + | |
| 3533 | + | |
| 3534 | + | |
| 3535 | + | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + | |
| 3539 | + | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
3459 | 3567 | | |
3460 | 3568 | | |
3461 | 3569 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
79 | | - | |
80 | | - | |
| 81 | + | |
| 82 | + | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
| |||
224 | 226 | | |
225 | 227 | | |
226 | 228 | | |
227 | | - | |
| 229 | + | |
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
| |||
246 | 248 | | |
247 | 249 | | |
248 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
249 | 263 | | |
250 | 264 | | |
251 | 265 | | |
| |||
275 | 289 | | |
276 | 290 | | |
277 | 291 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
282 | 301 | | |
283 | 302 | | |
284 | 303 | | |
| |||
328 | 347 | | |
329 | 348 | | |
330 | 349 | | |
| 350 | + | |
331 | 351 | | |
332 | 352 | | |
333 | 353 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| |||
0 commit comments