You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #51729 [AssetMapper] Allow simple, relative paths in importmap.php (weaverryan)
This PR was squashed before being merged into the 6.4 branch.
Discussion
----------
[AssetMapper] Allow simple, relative paths in importmap.php
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | None
| License | MIT
| Doc PR | TODO
This PR is based on top of #51543 - so that needs to be merged first.
Currently, the `path` key in `importmap.php` MUST be the logic path to an file. Especially when trying to refer to assets in a bundle, this forces us to use paths that... don't look very obvious to users - e.g.
```php
'app' => [
'path' => 'app.js',
],
'`@symfony`/stimulus-bundle' => [
'path' => '`@symfony`/stimulus-bundle/loader.js',
],
```
This PR adds support for relative paths (starting with `.`). This means the `importmap.php` file can look like this now:
```php
'app' => [
'path' => './assets/app.js',
],
'`@symfony`/stimulus-bundle' => [
'path' => './vendor/symfony/stimulus-bundle/assets/dist/loader.js',
],
```
Those paths are now simple. One less thing to explain to people.
Commits
-------
978b14d [AssetMapper] Allow simple, relative paths in importmap.php
thrownew \LogicException(sprintf('The path "%s" of the package "%s" cannot be found in any asset map paths.', $requireOptions->path, $requireOptions->packageName));
337
-
}
333
+
if (!$asset = $this->findAsset($path)) {
334
+
thrownew \LogicException(sprintf('The path "%s" of the package "%s" cannot be found: either pass the logical name of the asset or a relative path starting with "./".', $requireOptions->path, $requireOptions->packageName));
thrownew \InvalidArgumentException(sprintf('The path "%s" of the entrypoint "%s" mentioned in "importmap.php" cannot be found in any asset map paths.', $rootImportEntries->get($entryName)->path, $entryName));
504
508
}
@@ -529,4 +533,20 @@ private static function getImportMapTypeFromFilename(string $path): ImportMapTyp
0 commit comments