Skip to content
Snippets Groups Projects
Commit 742cc1df authored by Benjamin Franzke's avatar Benjamin Franzke
Browse files

[TASK] Use ES11 import syntax for dynamic typescript imports

ECMAScript 2020 (ES11) introduced dynamic imports.
TypeScript offers automatic type checking and resolution
for the dynamic import syntax (when using static strings)
and is able to transpile to require() calls in AMD output mode.

Therefore all occurences where a require() is used
directly, are migrated to the import syntax.

Notes:

* This change has a slight drawback: the generated code
  is slighter in order to add runtime detections for
  ES6 vs AMD style default.
  Although, this only applies in TypeScript AMD mode and
  will be compensated once switching to native ES6 modules.

* top.require() calls are left as-is for now, as this cases
  can't be changed to top.import():
    Property 'import' does not exist on type 'Window'
  Also something isn't available in native ES11 imports:
    TypeError: top.import is not a function

  We'll rather need a messaging api between the frames that
  allows to load top-level modules via import() in future.

Resolves: #96326
Related: #96323
Releases: main
Change-Id: Ia389da64255fb1fee76a4fbb0d2abdfc277921e1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72619


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarJochen <rothjochen@gmail.com>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenjamin Franzke <bfr@qbus.de>
Reviewed-by: default avatarJochen <rothjochen@gmail.com>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarBenjamin Franzke <bfr@qbus.de>
parent 0cea2713
Branches
Tags
Showing
with 40 additions and 29 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment