Bug #101373
closedext:form does not load from dynamicJavaScriptModules because ext:core ImportMap does not include the JS files
100%
Description
EXT:form
, running on TYPO3 12. I wanted to use the latest v12 JavaScript register method, as mentioned in the docs:
- https://docs.typo3.org/c/typo3/cms-form/12.4/en-us/I/Concepts/FormEditor/Index.html#register-custom-javascript-modules
- https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-96510-InfrastructureForJavaScriptModulesAndImportmaps.html
- https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Deprecation-96568-RequireJSModulesInFormFramework.html
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.