Skip to content

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Oct 14, 2025

Q A
Branch? 8.1
Bug fix? no
New feature? no
Deprecations? no
Issues -
License MIT

This should improve the discoverability of the entries in the importmap.php file.

@nicolas-grekas nicolas-grekas force-pushed the am-shape branch 2 times, most recently from d939f9d to 9975f5d Compare October 14, 2025 10:14
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a test that calls this function to be explicit about its intended use.

@nicolas-grekas nicolas-grekas changed the title [AssetMapper] Describe the shape in importmap.php using ImportMap::config() [AssetMapper] Describe the shape in importmap.php using the importmap() function Oct 14, 2025
@nicolas-grekas
Copy link
Member Author

why not creating a function like other config loaders do?

Good idea, PR updated!
About the test: this is already tested - when testing the generated importmap.php files.

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the test: this is already tested - when testing the generated importmap.php files.

Ok for the code execution, but we don't analyze the importmap.php file with psalm. We don't validate that the array matches the array-shape.

One of this files can be updated:

@nicolas-grekas
Copy link
Member Author

👍 I updated both

@Kocal
Copy link
Member

Kocal commented Oct 14, 2025

How things will behave if a project has a importmap.php with the importmap() function, Symfony Flex, and run composer require with an UX package that defines JS dependencies?

Related to https://github.com/symfony/flex/blob/f356aa35f3cf3d2f46c31d344c1098eb2d260426/src/PackageJsonSynchronizer.php#L260-L318, I don't think Flex will be able to parse this importmap.php

@nicolas-grekas
Copy link
Member Author

I don't think Flex will be able to parse this importmap.php

And you're right.

Status: needs work

@nicolas-grekas nicolas-grekas changed the title [AssetMapper] Describe the shape in importmap.php using the importmap() function [AssetMapper] Describe the shape of importmaps Dec 16, 2025
@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Dec 16, 2025

I don't think Flex will be able to parse this importmap.php

I fixed this by not wrapping in a function call. This now uses an inline @return annotation, which phpstan et al. don't understand but might in the future. That's sill better than nothing IMHO, at least for human readers for now.

Status: needs review

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tooling will be improved to support this.

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.

6 participants