Commit 54b8dca
Add
Summary:
Adds a `ProjectConfig::create_path_for_extra_artifact()` helper in `relay-config` and a `shard_extra_artifacts` `FeatureFlag` in the shared OSS `FeatureFlags`. The helper mirrors `create_path_for_artifact()` (honoring `shardOutput` / `shardStripRegex`) but is rooted at `extraArtifactsOutput`, with sharding gated by an explicit `should_shard` argument so callers can roll it out behind a flag. No OSS call sites use the flag today — internal PHP text-artifact generation is the only current consumer.
---
Today, generated PHP text artifacts (`RelayOperation.php`, `RelayFragment.php`) are written to a flat directory under `extraArtifactsOutput`, ignoring the project's `shardOutput` / `shardStripRegex` configuration. Normal JS artifacts use `ProjectConfig::create_path_for_artifact()` which shards output into subdirectories mirroring the source file's relative path — but the PHP codepath bypasses this entirely with a simple `extra_artifacts_output.join(filename)`.
This diff adds:
- A new `ProjectConfig::create_path_for_extra_artifact()` helper in `relay-config` that mirrors the sharding logic of `create_path_for_artifact()` but rooted at `extra_artifacts_output`. It takes an explicit `should_shard: bool` so callers can gate the behavior during rollout.
- A `shard_extra_artifacts` `FeatureFlag` in the OSS `FeatureFlags` struct (same pattern as `text_artifacts` — both control FB-only PHP generation but live in the shared config for consistency with the `"featureFlags"` JSON block).
- Wiring in `text_artifacts_generators.rs` to call the new helper, checking `feature_flags.shard_extra_artifacts.is_enabled_for(source_name)`.
- Simplification of the `FBProjectConfig` fallback construction in `main.rs` to use `..Default::default()` (prevents breakage when new fields are added).
- 5 unit tests covering: sharded with regex, sharded without regex, unsharded, shard flag ignored when project doesn't shard, and panic on missing `extra_artifacts_output`.
When the flag is disabled (default), behavior is identical to today. When enabled, PHP artifacts are placed in subdirectories matching the source file layout (e.g. `flib/__generated__/.../js/enterprise/ui/foo/BarRelayOperation.php` instead of flat `flib/__generated__/.../BarRelayOperation.php`).
Note: the Hack preloader (`hack_query_preloader.rs`) has the same flat-path issue but is intentionally not changed in this diff — follow-up.
Reviewed By: evanyeung
Differential Revision: D105719732
fbshipit-source-id: 2cd22a6d1db50a9c3b833a0b1ed07eef43ccceefshard_extra_artifacts feature flag to shard PHP text artifacts1 parent 6ed5470 commit 54b8dca
2 files changed
Lines changed: 135 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
| |||
223 | 229 | | |
224 | 230 | | |
225 | 231 | | |
| 232 | + | |
226 | 233 | | |
227 | 234 | | |
228 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
450 | 494 | | |
451 | 495 | | |
452 | 496 | | |
| |||
533 | 577 | | |
534 | 578 | | |
535 | 579 | | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
0 commit comments