From e51b165468612ccc055aa6743d486ea7cadc35a3 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sat, 11 Jul 2026 12:01:37 +0200 Subject: [PATCH] Read and resolve `entrypoints.json` in RepriseBundle First slice of the PHP consumer bundle -- the read foundation: - Value objects for the self-describing entrypoints.json (Entrypoints, Entry, DevServer) with validating fromArray() factories. - EntrypointsLookup (+ interface): resolves an entry's js/css/preload/dynamic URLs, deduplicates a chunk shared by several entries within one request, exposes the integrity map and the build mode, and supports strict / non-strict lookups. - ResetAssetsEventListener clears the per-request dedup state when the main request finishes (long-running workers). - Bundle config (output_path, strict_mode) + service wiring; the interface is autowirable so user code can inject it (e.g. rendering several times / PDF). Also record ADR 0001 (doc/adr/): asset URLs will be resolved through symfony/asset Packages at render time (base_path + base_urls), which the TagRenderer slice builds on. Rendering (Twig tags, the render event, dev-server client injection) and WebLink preload land in the next slices. --- docs/adr/0001-packages-driven-asset-urls.md | 67 ++++++++ src/Asset/DevServer.php | 46 ++++++ src/Asset/Entry.php | 71 ++++++++ src/Asset/Entrypoints.php | 101 ++++++++++++ src/Asset/EntrypointsLookup.php | 151 ++++++++++++++++++ src/Asset/EntrypointsLookupInterface.php | 56 +++++++ .../ResetAssetsEventListener.php | 48 ++++++ src/Exception/EntrypointNotFoundException.php | 21 +++ .../EntrypointsFileNotFoundException.php | 21 +++ src/Exception/ExceptionInterface.php | 21 +++ src/Exception/InvalidEntrypointsException.php | 21 +++ src/RepriseBundle.php | 49 ++++++ .../Asset/EntrypointsLookupFunctionalTest.php | 43 +++++ tests/Asset/EntrypointsLookupTest.php | 122 ++++++++++++++ tests/Asset/EntrypointsTest.php | 114 +++++++++++++ .../ResetAssetsEventListenerTest.php | 54 +++++++ tests/Kernel/AppKernelTrait.php | 5 - tests/Kernel/EmptyAppKernel.php | 5 - tests/Kernel/FrameworkAppKernel.php | 5 - tests/Kernel/FunctionalAppKernel.php | 68 ++++++++ tests/Kernel/LookupConsumer.php | 25 +++ tests/RepriseBundleTest.php | 2 +- tests/fixtures/build/entrypoints.json | 23 +++ tests/fixtures/dev/entrypoints.json | 13 ++ tests/fixtures/malformed/entrypoints.json | 1 + 25 files changed, 1137 insertions(+), 16 deletions(-) create mode 100644 docs/adr/0001-packages-driven-asset-urls.md create mode 100644 src/Asset/DevServer.php create mode 100644 src/Asset/Entry.php create mode 100644 src/Asset/Entrypoints.php create mode 100644 src/Asset/EntrypointsLookup.php create mode 100644 src/Asset/EntrypointsLookupInterface.php create mode 100644 src/EventListener/ResetAssetsEventListener.php create mode 100644 src/Exception/EntrypointNotFoundException.php create mode 100644 src/Exception/EntrypointsFileNotFoundException.php create mode 100644 src/Exception/ExceptionInterface.php create mode 100644 src/Exception/InvalidEntrypointsException.php create mode 100644 tests/Asset/EntrypointsLookupFunctionalTest.php create mode 100644 tests/Asset/EntrypointsLookupTest.php create mode 100644 tests/Asset/EntrypointsTest.php create mode 100644 tests/EventListener/ResetAssetsEventListenerTest.php create mode 100644 tests/Kernel/FunctionalAppKernel.php create mode 100644 tests/Kernel/LookupConsumer.php create mode 100644 tests/fixtures/build/entrypoints.json create mode 100644 tests/fixtures/dev/entrypoints.json create mode 100644 tests/fixtures/malformed/entrypoints.json diff --git a/docs/adr/0001-packages-driven-asset-urls.md b/docs/adr/0001-packages-driven-asset-urls.md new file mode 100644 index 0000000..9f6670b --- /dev/null +++ b/docs/adr/0001-packages-driven-asset-urls.md @@ -0,0 +1,67 @@ +# 1. Packages-driven asset URL resolution + +- Status: Accepted +- Date: 2026-07-11 + +## Context + +The `@symfony/reprise` plugin currently writes `entrypoints.json` with **final** URLs +(content-hashed filenames, prefixed with `publicPath`), and `RepriseBundle` would render the +`