Review main Merged

72619[TASK] Use ES11 import syntax for dynamic typescript imports

Benjamin Franzke CR +2 V +2 Normal +53 −42 updated 12/13/21, 12:28

Commit message

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.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Jochen Roth +1
    • Benni Mack +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Jochen Roth +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 31

Show 11 more files

Review log 1317

  1. Benjamin Franzke uploaded patch set 1 12/10/21, 12:51

  2. Benjamin Franzke wrote 12/10/21, 12:51

    Topic set to esm
  3. core-ci voted on patch set 1 V +1 12/10/21, 13:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20937

  4. Jochen Roth rebased onto patch set 2 12/10/21, 14:16

  5. core-ci voted on patch set 2 V +1 12/10/21, 14:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20942

  6. Benni Mack commented on patch set 2 12/10/21, 14:49

    SystemMaintainer.ts:35

    this one?
  7. Benjamin Franzke commented on patch set 2 12/10/21, 14:59

    SystemMaintainer.ts:35 Reply

    yea, sorry, wanted to add a sentence to the commit message that top.require is excluded as these cases can't be transpiled when changed to top.import. And they wouldn't work with native ES6 (there is nothing like top.import): TypeError: top.import is not a function Seems I forgot to mention that, will do. We'll rather need a messaging api between the frames that allows to load top-level modules via import(). Therefore I'd leave that out of this patch.
  8. Benjamin Franzke updated the commit message in patch set 3 12/10/21, 15:04

  9. Benjamin Franzke commented on patch set 3 12/10/21, 15:04

    SystemMaintainer.ts:35 Reply

    Done
  10. core-ci voted on patch set 3 V +1 12/10/21, 15:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20945

  11. Benjamin Franzke uploaded patch set 4 12/10/21, 23:59

  12. core-ci voted on patch set 4 V +1 12/11/21, 00:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20972

  13. Jochen Roth voted on patch set 4 V +1 CR +1 12/13/21, 10:02

  14. Benni Mack voted on patch set 4 CR +1 12/13/21, 11:44

  15. Benni Mack voted on patch set 4 V +1 12/13/21, 11:54

  16. Benjamin Franzke voted on patch set 4 V +2 CR +2 12/13/21, 12:28

  17. Benjamin Franzke merged patch set 5 12/13/21, 12:28