Skip to content

Commit 522d99f

Browse files
committed
feature #52024 [AssetMapper] Add a "package specifier" to importmap in case import name != package+path (weaverryan)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [AssetMapper] Add a "package specifier" to importmap in case import name != package+path | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | yes | Deprecations? | no | Tickets | None | License | MIT Hi! Sorry for the large PR - this tightens up the component after the many recent enhancements. `tl;dr` Makes "vendor" importmap entries work identically to "local" entries when it comes to preloading (a bug). Also tightens up `ImportMapEntry`, which is a tricky class because if an entry is "remote", it has 2 extra, required, properties. Full changes: * Make ImportMapEntry stricter so that, when remote, version & packageModuleSpecifier are always set. * Set the "path" property always for ImportMapEntry, making them no different than local files through most of the system. * Related, fix a bug where if a vendor .js file imported another module, that other module was not previously preloaded when the vendor module was preloaded. * Fix a bug with downloaded package paths if you include a specific package - chart.js - and also a path - chart.js/auto. Previously, this would try to create both a file and directory called chart.js, * Fix bug where imports weren't matching if some spaces were missing Cheers! Commits ------- c80a1abf8b4 [AssetMapper] Add a "package specifier" to importmap in case import name != package+path
2 parents 2a7613b + e40fa51 commit 522d99f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,8 +1363,8 @@ private function registerAssetMapperConfiguration(array $config, ContainerBuilde
13631363
->setArgument(1, $config['missing_import_mode']);
13641364

13651365
$container
1366-
->getDefinition('asset_mapper.importmap.remote_package_downloader')
1367-
->replaceArgument(2, $config['vendor_dir'])
1366+
->getDefinition('asset_mapper.importmap.remote_package_storage')
1367+
->replaceArgument(0, $config['vendor_dir'])
13681368
;
13691369
$container
13701370
->getDefinition('asset_mapper.mapped_asset_factory')

Resources/config/asset_mapper.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use Symfony\Component\AssetMapper\ImportMap\ImportMapRenderer;
3636
use Symfony\Component\AssetMapper\ImportMap\ImportMapUpdateChecker;
3737
use Symfony\Component\AssetMapper\ImportMap\RemotePackageDownloader;
38+
use Symfony\Component\AssetMapper\ImportMap\RemotePackageStorage;
3839
use Symfony\Component\AssetMapper\ImportMap\Resolver\JsDelivrEsmResolver;
3940
use Symfony\Component\AssetMapper\MapperAwareAssetPackage;
4041
use Symfony\Component\AssetMapper\Path\PublicAssetsPathResolver;
@@ -145,6 +146,7 @@
145146
->set('asset_mapper.importmap.config_reader', ImportMapConfigReader::class)
146147
->args([
147148
abstract_arg('importmap.php path'),
149+
service('asset_mapper.importmap.remote_package_storage'),
148150
])
149151

150152
->set('asset_mapper.importmap.manager', ImportMapManager::class)
@@ -157,11 +159,16 @@
157159
])
158160
->alias(ImportMapManager::class, 'asset_mapper.importmap.manager')
159161

162+
->set('asset_mapper.importmap.remote_package_storage', RemotePackageStorage::class)
163+
->args([
164+
abstract_arg('vendor directory'),
165+
])
166+
160167
->set('asset_mapper.importmap.remote_package_downloader', RemotePackageDownloader::class)
161168
->args([
169+
service('asset_mapper.importmap.remote_package_storage'),
162170
service('asset_mapper.importmap.config_reader'),
163171
service('asset_mapper.importmap.resolver'),
164-
abstract_arg('vendor directory'),
165172
])
166173

167174
->set('asset_mapper.importmap.resolver', JsDelivrEsmResolver::class)

0 commit comments

Comments
 (0)