From 0e13d21ac9771f6a6d6c9ebfe594d206c61f6611 Mon Sep 17 00:00:00 2001 From: Claus Due Date: Mon, 28 Oct 2024 15:01:57 +0100 Subject: [PATCH] [TASK] Use JS module loader instead of requirejs when available --- .../HookSubscribers/EditDocumentController.php | 6 +++++- Classes/Integration/PreviewRenderer.php | 6 +++++- Configuration/JavaScriptModules.php | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 Configuration/JavaScriptModules.php diff --git a/Classes/Integration/HookSubscribers/EditDocumentController.php b/Classes/Integration/HookSubscribers/EditDocumentController.php index 176a368da..8fc5a1370 100644 --- a/Classes/Integration/HookSubscribers/EditDocumentController.php +++ b/Classes/Integration/HookSubscribers/EditDocumentController.php @@ -16,6 +16,10 @@ public function requireColumnPositionJavaScript() : void { /** @var PageRenderer $pageRenderer */ $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $pageRenderer->loadRequireJsModule('TYPO3/CMS/Flux/FluxColPosAssignment'); + if (method_exists($pageRenderer, 'loadJavaScriptModule')) { + $pageRenderer->loadJavaScriptModule('@fluidtypo3/flux/FluxColPosAssignment.js'); + } else { + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Flux/FluxColPosAssignment'); + } } } diff --git a/Classes/Integration/PreviewRenderer.php b/Classes/Integration/PreviewRenderer.php index bf38986a4..819561db4 100644 --- a/Classes/Integration/PreviewRenderer.php +++ b/Classes/Integration/PreviewRenderer.php @@ -56,7 +56,11 @@ protected function attachAssets(): void { if (!static::$assetsIncluded) { $this->pageRenderer->addCssFile('EXT:flux/Resources/Public/css/flux.css'); - $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Flux/FluxCollapse'); + if (method_exists($this->pageRenderer, 'loadJavaScriptModule')) { + $this->pageRenderer->loadJavaScriptModule('@fluidtypo3/flux/FluxCollapse.js'); + } else { + $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Flux/FluxCollapse'); + } static::$assetsIncluded = true; } diff --git a/Configuration/JavaScriptModules.php b/Configuration/JavaScriptModules.php new file mode 100644 index 000000000..56073fb4f --- /dev/null +++ b/Configuration/JavaScriptModules.php @@ -0,0 +1,8 @@ + ['core', 'backend'], + 'imports' => [ + '@fluidtypo3/flux/' => 'EXT:flux/Resources/Public/JavaScript/', + ] +];