Project

General

Profile

Actions

Bug #101373

closed

ext:form does not load from dynamicJavaScriptModules because ext:core ImportMap does not include the JS files

Added by Stefan P almost 1 year ago. Updated 8 days ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend JavaScript
Target version:
-
Start date:
2023-07-18
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I have an extension that adds a new form element defintion to EXT:form, running on TYPO3 12. I wanted to use the latest v12 JavaScript register method, as mentioned in the docs:

In the form editor YAML, if I replace the deprecated dynamicRequireJsModules with dynamicJavaScriptModules, add the JavaScriptModules.php file and adjust the format of the js file accordingly, I get this error in the Browser console:
Unable to resolve specifier '@myvendor/my-extension/Backend/FormEditor/ViewModel.js'

So, the YAML is correctly parsed and the correct file should be loaded. Dumping the import map inside the JavaScriptModules.php loader, I can also see that this is registering my JS file with the same structure as every other JS file from core extensions.

But it still can not be resolved and loaded in the Browser. I tried upper and lowercase names (bot in actual file names as well in the config files), different ways of writing the EXT key (like "my_extension" and "my-extension"). I looked how core extensions register JS modules and adapted my code. Nothing works.

Using the deprecated v11 way works without any problems.

Is this a bug in the form extension or is something missing in the documentation?

UPDATE: I found out that my extension is not in the variable $extensionsToLoad in the class ImportMap . How to get it in there? In the original $importMap (loaded from JavaScriptModules.php) it is correctly included, but in the final resolved one that is passed to the FE it is not included, because my extension key is not in $extensionsToLoad.

This seems to be because in ImportMap::resolveImport around line 106 the helper.js of EXT:form is not yet available. At least this is the situation why for my extension the ImportMap::loadDependencies('my-package') is not executed.

Actions

Also available in: Atom PDF