No Code Attached Yet
avatar skurvish
skurvish
9 Jun 2025

Steps to reproduce the issue

Install J! into a subdirectory. Install a component that has its assets in a folder structure such as media/com_example/js etc. Create assets in the joomla.asset.json file that have as part of their name com_example or even example.

Expected result

Whe we use WAM to useScript("com_example.example") we expect the media/com_example/js/example.js file to be loaded and or importmap to include it.

Actual result

The scriptsRenderer cannot find the file when in a subfolder. The getUri logic seems to break.

System information (as much as possible)

Tested on J5.3.1
PHP 8.3

Additional comments

I renamed my asset names so they did not conflict with the uri path name and it circumvented the problem.

avatar skurvish skurvish - open - 9 Jun 2025
avatar skurvish skurvish - change - 9 Jun 2025
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 9 Jun 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 9 Jun 2025
avatar skurvish skurvish - change - 9 Jun 2025
The description was changed
avatar skurvish skurvish - edited - 9 Jun 2025
avatar Fedik
Fedik - comment - 10 Jun 2025

I cannot reproduce it.
Please provide more information:

  • example of the element asset
  • the javascript file location
  • information where and how do you load your assets
avatar Fedik Fedik - change - 10 Jun 2025
Labels Added: Information Required
avatar Fedik Fedik - labeled - 10 Jun 2025
avatar skurvish
skurvish - comment - 10 Jun 2025

Happy to. For context I have a system plugin that inserts two asset files: joomla.asset.json (my main component assets) and libs.asset.json (some supporting libraries). Almost all javascript assets in both files are es6 modules. Each asset file has a preset that has multiple dependencies and this preset is imported via a usePreset by the plugin following adding the asset files to the registry so that all of these modules get into the import map. This works perfectly when Joomla is installed in the root public_html folder. I should also note that the libs assets always get into the importmap.

Here is an example asset from my main joomla.asset.json file:
{
"name": "fabrik.namespace",
"type": "script",
"uri": "fabrik/com_fabrik/admin/namespace.js",
"module" : true,
"importmap": true,
"importmapName": "@fbnamespace"
},
The actual file path is media/fabrik/com_fabrik/js/admin/namespace.js (again this works perfectly without the subfolder)

Inside a subfolder it fails. If I suimply change the asset name to "fabric.namespace" it works.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45587.
avatar Fedik Fedik - change - 10 Jun 2025
Labels Removed: Information Required
avatar Fedik Fedik - unlabeled - 10 Jun 2025
avatar Fedik
Fedik - comment - 10 Jun 2025

your example works fine for me:

Image

As you can see Joomla installation in /jdev5 subfolder, and the file still loaded.

avatar skurvish skurvish - change - 10 Jun 2025
Status New Closed
Closed_Date 0000-00-00 00:00:00 2025-06-10 10:48:12
Closed_By skurvish
avatar skurvish skurvish - close - 10 Jun 2025
avatar skurvish
skurvish - comment - 10 Jun 2025

Well that is just weird. I will have to do some more digging then. Thanks. I am closing this for the time being.

avatar Fedik
Fedik - comment - 10 Jun 2025

Maybe there some other plugin doing override, or something else is missing.
Hard to say.

avatar Fedik
Fedik - comment - 10 Jun 2025

btw, it can be an issue when you register your joomla.asset.json with wrong path.

avatar skurvish
skurvish - comment - 10 Jun 2025

I found the issue, it was not Joomla. In my system plugin if I had a debug flag set, I wanted to disable the automatic versioning on my assets for I ran through them all and replaced the existing assets with a modified one. In doing so I was calling $item->getUri() not realizing that the default action is to resolve the path so I was inserting a fully resolved path into the uri. Changing the call to $item->getUri(false) fixed the problem.

Thank you again for your assistance and sorry for the work I put you through.

Add a Comment

Login with GitHub to post a comment