Skip to content

[AssetMapper] Adding infos to be forwarded to package maintainers in case of error #19565

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
Mar 25, 2024

Conversation

ThomasLandauer
Copy link
Contributor

Page: https://symfony.com/doc/6.4/frontend/asset_mapper.html#importing-3rd-party-javascript-packages

Closes #19558

Thanks to @tofsjonas for figuring this out at tofsjonas/sortable#68

You might say it's not the job of the Symfony docs to tell JavaScript package maintainers how to set up their packages.

But: With so many packages out there, I doubt that importing them will always work. So instead of leaving Symfony users back frustrated, I think it's better to tell them what they can do. And that it's not AssetMapper's fault that it didn't work out.


If you're getting a 404 error, you can contact the package maintainer and ask them to
include `"main":` and `"module":` to the package's `package.json`.

Copy link
Member

Choose a reason for hiding this comment

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

This cut the example in two. Could you group your two additions in a dedicated paragraph ?

And a 404 could have many other reasons, i fear this could be misdirecting :|

@@ -207,6 +212,8 @@ This adds the ``bootstrap`` package to your ``importmap.php`` file::
such as ``@popperjs/core``. The ``importmap:require`` command will add both the
main package *and* its dependencies. If a package includes a main CSS file,
that will also be added (see :ref:`Handling 3rd-Party CSS <asset-mapper-3rd-party-css>`).
If the associated CSS file isn't added to the importmap, you can contact the package
Copy link
Member

Choose a reason for hiding this comment

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

This should be in the "handling 3rd party" section, as this paragraph states "if a packages includes a CSS files".

@ThomasLandauer
Copy link
Contributor Author

Yeah, you're right, there is no good place for this currently. So I'd like to reorganize the sections and merge "Importing 3rd Party JavaScript Packages" with "Handling 3rd-Party CSS" and move them downwards, under the CSS section.

Reasons:

  • 3rd party JavaScript comes too early, IMO. How the importmap works at all should be explained first.
  • Same for CSS: People need to understand how their own CSS works first, before caring about 3rd party CSS.
  • Many external packages contain CSS, so it's better to deal with these two topics (3rd party JS and 3rd party CSS) in one section. Then the content of this PR would fit there nicely.

What do you think?

@smnandre
Copy link
Member

As i see it, required JS packages is the main reason to use importmaps.

CSS files is just a bonus, for those who want to install them.

@javiereguiluz
Copy link
Member

I like this proposal. Two quick comments:

(1) This:

include `"main":` and `"module":` to the package's `package.json`

maybe can be reworded as follows to make it more clear:

include the `main` and `module` options to the package's `package.json`

(2) Do we have a reference for the package.json format? Ideally I'd like to add a link so people can read more about these new options that they need to add.

Thanks.

@ThomasLandauer
Copy link
Contributor Author

ThomasLandauer commented Feb 16, 2024

@javiereguiluz OK, but where to put it? What do you think about merging the two sections (see above)?

@smnandre No matter what people are using it for: I think handling local files should be explained first, to make people understand the basics.

@smnandre
Copy link
Member

I'm just stating a fact: AssetMapper may be for local CSS files first..

But ImportMap is a tool made for 3rd party scripts / dependencies first.

@javiereguiluz javiereguiluz merged commit 3865de3 into symfony:6.4 Mar 25, 2024
@javiereguiluz
Copy link
Member

javiereguiluz commented Mar 25, 2024

Thanks Thomas! This is now merged. I reworded and changed the location a bit as mentioned in the discussion. See 64eb515

@ThomasLandauer ThomasLandauer deleted the patch-17 branch March 25, 2024 17:09
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