Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[AssetMapper] Render a more precise importmap per page#60897
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
javiereguiluz wants to merge1 commit intosymfony:7.4Choose a base branch fromjaviereguiluz:better_importmaps
base:7.4
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+3 −2
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
i fear this will break all the lazy loading of Stimulus controllers |
There are very valid reasons to have in the importmap assets you do not require to load 100% of the time on load What you want to look at is the But this would be a BC break and will require some form of flag. |
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Twig template in a Symfony app uses AssetMapper like this:
In the rendered HTML page, the
<head>
section will include this:(1), (3) and (4) are already perfect: they contain only what this page needs.
(2) is problematic IMO, because it discloses ALL the importmap entries of the application, including everything you'll never use in this page. In the past we've discussed about this and I want to bring this up again.
The problem is not about adding some unnecessary contents to the page(it's just a few bytes, so this is irrelevant). The problem is that the full importmap shows private things(think of the backend, etc.) and things that should not be public yet(new sections to be announced in the futurte, WIP sections, etc.). For these reasons, exposing all importmap entries in all pages is not OK for me.
In this PR, I made some minor changes that fix this. Now, the
importmap
only includes the entries relevant for this page, hiding everything else.It works in my tests, but I may have missed edge cases. Feedback welcome! Thanks!