Skip to content

[AssetMapper] Only download a CSS file if it is explicitly advertised #52524

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

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

weaverryan
Copy link
Member

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues None
License MIT

When we download a JS package, we check to see if that JS package has a CSS file. And if it does, we add that too. This is purely to be helpful. For example, importmap:require bootstrap grabs the Bootstrap CSS file.

A JavaScript package can explicitly advertise that it has a CSS file or jsdelivr can "guess". It tells us if it's guessing or not:

I propose we only grab the CSS file if it's a "sure thing". Right now, when you install tom-select, it's grabbing a CSS file that... we certainly don't use and I'm not sure if anyone does. It'd be better if it grabbed nothing. And, if needed (probably will be), we an make Flex install any enabled "autoimports" - e.g. https://github.com/symfony/ux/blob/2.x/src/Autocomplete/assets/package.json#L17

Overall, I'm still tweaking with the ideal UX here. I think life will be better if we only install "for sure" CSS files.

Thanks!

@weaverryan weaverryan force-pushed the asset-mapper-only-exact-css-files branch from 335c460 to 1f41d67 Compare November 10, 2023 02:35
@WebMamba
Copy link
Contributor

Just speaking from a DX perspective: I think we should ALWAYS grab the CSS file. A lot of js packages have small CSS files, but without it, everything can look a bit buggy. And I think CSS is part of the packages, the maintainer chooses to add CSS in their packages, so we should follow this decision. And I think it's easier if we don't have to run two commands one to install the CSS and on for the Js.

@weaverryan
Copy link
Member Author

And I think CSS is part of the packages, the maintainer chooses to add CSS in their packages, so we should follow this decision

I totally agree. But if that's the case, they will / should advertise that they have a CSS file - e.g. via the style key in package.json. If they haven't done this, then that's an indication that there is no one, main CSS file.

@fabpot fabpot merged commit 541c80c into symfony:6.4 Nov 10, 2023
This was referenced Nov 10, 2023
@weaverryan weaverryan deleted the asset-mapper-only-exact-css-files branch November 11, 2023 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants