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.
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.
The scriptsRenderer cannot find the file when in a subfolder. The getUri logic seems to break.
Tested on J5.3.1
PHP 8.3
I renamed my asset names so they did not conflict with the uri path name and it circumvented the problem.
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
Information Required
|
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.
Labels |
Removed:
Information Required
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-06-10 10:48:12 |
Closed_By | ⇒ | skurvish |
Well that is just weird. I will have to do some more digging then. Thanks. I am closing this for the time being.
Maybe there some other plugin doing override, or something else is missing.
Hard to say.
btw, it can be an issue when you register your joomla.asset.json
with wrong path.
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.
I cannot reproduce it.
Please provide more information: