Skip to content

[Integrity] Emit Subresource Integrity hashes in entrypoints.json - #12

Merged
Kocal merged 1 commit into
symfony:mainfrom
Kocal:feat/subresource-integrity
Jul 11, 2026
Merged

[Integrity] Emit Subresource Integrity hashes in entrypoints.json#12
Kocal merged 1 commit into
symfony:mainfrom
Kocal:feat/subresource-integrity

Conversation

@Kocal

@Kocal Kocal commented Jul 11, 2026

Copy link
Copy Markdown
Member
Q A
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #...
License MIT

Add an opt-in integrity: { enabled, algorithms? } option (default ['sha384'])
that writes an integrity map (asset URL -> SRI hash) into entrypoints.json, for
Reprise's Symfony bundle (src/RepriseBundle.php, still a stub) to render as
integrity="..." on the script/link tags. This change is JS-only.

Hashes are computed from the files on disk after each bundler finishes emitting: the
Rspack done hook and a Vite writeBundle hook both read the emitted files back and
hash them. In-memory hashing does not work for Vite because it finalizes chunks (e.g.
replacing __VITE_PRELOAD__) only when writing to disk, so the shipped bytes differ
from the bundle. Every referenced file per entry (js/css/preload/dynamic) is covered.

Build only -- the dev server serves changing in-memory assets, so no hashes there.

@Kocal Kocal self-assigned this Jul 11, 2026
@Kocal
Kocal force-pushed the feat/subresource-integrity branch from 553c518 to 2a03a2f Compare July 11, 2026 04:58
Add an opt-in `integrity: { enabled, algorithms? }` option (default `['sha384']`)
that writes an `integrity` map (asset URL -> SRI hash) into entrypoints.json, for
Reprise's Symfony bundle (src/RepriseBundle.php, still a stub) to render as
integrity="..." on the script/link tags. This change is JS-only.

Hashes are computed from the files on disk after each bundler finishes emitting: the
Rspack `done` hook and a Vite `writeBundle` hook both read the emitted files back and
hash them. In-memory hashing does not work for Vite because it finalizes chunks (e.g.
replacing `__VITE_PRELOAD__`) only when writing to disk, so the shipped bytes differ
from the bundle. Every referenced file per entry (js/css/preload/dynamic) is covered.

Build only -- the dev server serves changing in-memory assets, so no hashes there.

Also correct the entrypoints/manifest consumer references to Reprise's own
RepriseBundle (not WebpackEncoreBundle) across AGENTS.md, README and docs, and
record the feature-name commit scope and the Vite/Rsbuild test-symmetry rule in
AGENTS.md.
@Kocal
Kocal force-pushed the feat/subresource-integrity branch from 2a03a2f to 9f16080 Compare July 11, 2026 05:10
@Kocal Kocal changed the title [Integrity][Tests][Docs] Emit Subresource Integrity hashes in entrypoints.json [Integrity] Emit Subresource Integrity hashes in entrypoints.json Jul 11, 2026
@Kocal
Kocal merged commit 27a3819 into symfony:main Jul 11, 2026
20 checks passed
@Kocal
Kocal deleted the feat/subresource-integrity branch July 11, 2026 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant