Skip to content

Commit 541c80c

Browse files
bug #52524 [AssetMapper] Only download a CSS file if it is explicitly advertised (weaverryan)
This PR was merged into the 6.4 branch. Discussion ---------- [AssetMapper] Only download a CSS file if it is explicitly advertised | 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: * Not guessing: https://data.jsdelivr.com/v1/packages/npm/bootstrap@5.0.0/entrypoints * Yes guessing: https://data.jsdelivr.com/v1/packages/npm/tom-select@2.3.1/entrypoints 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! Commits ------- 1f41d67 [AssetMapper] Only download a CSS file if it is explicitly advertised
2 parents 18d866c + 1f41d67 commit 541c80c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ public function resolvePackages(array $packagesToRequire): array
129129

130130
$entrypoints = $cssEntrypointResponse->toArray()['entrypoints'] ?? [];
131131
$cssFile = $entrypoints['css']['file'] ?? null;
132+
$guessed = $entrypoints['css']['guessed'] ?? true;
132133

133-
if (!$cssFile) {
134+
if (!$cssFile || $guessed) {
134135
continue;
135136
}
136137

src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public static function provideResolvePackagesTests(): iterable
224224
[
225225
'url' => '/v1/packages/npm/bootstrap@5.2.0/entrypoints',
226226
'response' => ['body' => ['entrypoints' => [
227-
'css' => ['file' => '/dist/css/bootstrap.min.css'],
227+
'css' => ['file' => '/dist/css/bootstrap.min.css', 'guessed' => false],
228228
]]],
229229
],
230230
[

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy