-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Asset] [DX] Option to make asset manifests strict on missing item #38495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Symfony/Component/Asset/VersionStrategy/RemoteJsonManifestVersionStrategy.php
Outdated
Show resolved
Hide resolved
c75560b
to
92d5fde
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! WebpackEncoreBundle has had this option for a long time - called strict_mode - for an entry that doesn’t appear in entrypoints.json
]) | ||
|
||
->set('assets.remote_json_manifest_version_strategy', RemoteJsonManifestVersionStrategy::class) | ||
->abstract() | ||
->args([ | ||
abstract_arg('manifest url'), | ||
service('http_client'), | ||
false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should both be abstract args - as we fill both in always
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used a fixed value to prevent breaking compatibility in the eventuality someone extends this abstract definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it something I must change ?
src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php
Outdated
Show resolved
Hide resolved
7d60341
to
abeb56c
Compare
src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Asset/VersionStrategy/RemoteJsonManifestVersionStrategy.php
Outdated
Show resolved
Hide resolved
abeb56c
to
ed5d943
Compare
This comment has been minimized.
This comment has been minimized.
ed7d12f
to
e76aea7
Compare
src/Symfony/Component/Asset/Exception/AssetNotFoundException.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php
Outdated
Show resolved
Hide resolved
e76aea7
to
e84046e
Compare
(small rebase needed) |
e84046e
to
90d903f
Compare
Rebased. The CS fix suggested by fabbot are not related to this PR. |
Rebased again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice proposal! Jérôme, thanks for contributing this feature. I hope it's merged 👍
Thank you @GromNaN. |
…ategy (GromNaN) This PR was merged into the 5.4 branch. Discussion ---------- [Asset] Add option $strictMode to JsonManifestVersionStrategy Documentation for symfony/symfony#38495 Commits ------- c4e19eb [Assets] Add doc for strict mode strategy
In all the projects I use a JSON manifest, when an asset is not listed in manifest.json, the asset file is not generated. The current behavior is permissive as it returns the unmodified path of the asset. Which ends with a 404 when the browser tries to load the asset.
With the option
strict_mode: true
, an exception is thrown when we try to use an asset that is not listed inmanifest.json
. Thereby we don't have to check that asset urls are actually working in tests (manual or automated).Usage:
The option
strict_mode
is optional for backward compatibility. Using the%kernel.debug%
value is safe to flush bugs on dev or test mode but keep the application working on production.Todo:
Update recipe ?