Bug #96374

Wrong include path calculated for RequireJS

Added by Francois Suter 5 months ago. Updated 5 months ago.

Status:
Resolved
Priority:
Must have
Assignee:
-
Category:
Backend JavaScript
Start date:
2021-12-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.0
Tags:
RequireJS
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

Context: a backend module (extension external_import) loads the 3rd-party library Datatables using:

            $publicResourcesPath = PathUtility::getAbsoluteWebPath(
                    ExtensionManagementUtility::extPath('external_import')
                ) . 'Resources/Public/';
            $pageRenderer = $view->getModuleTemplate()->getPageRenderer();
            $pageRenderer->addRequireJsConfiguration(
                [
                    'paths' => [
                        'datatables' => $publicResourcesPath . 'JavaScript/Contrib/jquery.dataTables'
                    ]
                ]
            );


This worked fine until TYPO3 11.5.3 and breaks with 11.5.4.

The reason is that the path is wrongly calculated as:

https://foo.com/var/www/html/vendor/cobweb/external_import/Resources/Public/JavaScript/Contrib/jquery.dataTables.js?bust=1639666788

instead of:

https://foo.com/typo3conf/ext/external_import/Resources/Public/JavaScript/Contrib/jquery.dataTables.js

#1

Updated by Francois Suter 5 months ago

This can be tested with the external_import extension. Just access the "Data Import" module and you should see a 404 error when trying to fetch the Datatables.js file. The visible effect is that the search field does nothing and that the table is not sorted in order of priority by default (however to have anything in the table, you also need to install extension "externalimport_tut").

#2

Updated by Oliver Hader 5 months ago

  • Status changed from New to Needs Feedback

(I assume that https://github.com/TYPO3/CmsComposerInstallers/releases/tag/v4.0.0-RC1 is used already in your particular project - in case it is not, please report back)

I've create a corresponding pull-request at https://github.com/cobwebch/external_import/pull/225 to change the path resolving.

Explanation

  • PathUtility::getAbsoluteWebPath('EXT:extension_name/') resolves to corresponding (private) folder in Composer vendor/ folder
  • PathUtility::getAbsoluteWebPath('EXT:extension_name/Resources/Public') resolves to (virtual) public path typo3conf/ext/
#4

Updated by Oliver Hader 5 months ago

  • Status changed from Needs Feedback to Resolved

Thx for the feedback! I'm closing this issue on the core-side. Please feel free to reopen, in case you think the TYPO3 core should behave differently here...

#5

Updated by Francois Suter 5 months ago

I just verified on my side too that it worked with both v10 and v11.

Before closing this issue, I'm wondering about that change in CMS Composer Installer. I don't remember any communication about it, and since it's not directly a change in TYPO3 itself, does it get any visibility as a breaking change?

Also available in: Atom PDF