Review main Abandoned

88595[TASK] Modernize JavaScript and CSS buildchain

Benjamin Franzke CR 0 V 0 Impossible +5649 −6421 updated 03/22/25, 16:04

Commit message

Use ECMAScript 2023 as TypeScript target
----------------------------------------

Use modern JavaScript targets for TypeScript and terser, and enable
terser `module` mode which allows to compress and mangle variables
and properties, based of the knowledge that the JavaScript are loaded
as modules (via `import`/`<script type="module">` and not as traditional
non-module `<script>` sources.

Replace clean-css with cssnano
------------------------------

Replace clean-css with cssnano, which is a native postcss plugin
that can operate on the postcss CSS AST directly, without the need
for an own CSS parser implementation.
This means that this plugins is less likely to miss support for new
CSS functionality like container queries (which clean-css – in the
version pulled in by postcss-clean – does not yet support).

Replace html-minifier with htmlnano
-----------------------------------

Replace the ancient library minify-html-literals with litnano (htmlnano
for lit template literals), as minify-html-literals pulls in insecure
dependencies and does not allow for asynchronous css processing
(needed for cssnano usage).

Allow generation of (temporary) JavaScript sourcemaps
-----------------------------------------------------

The TypeScript buildchain is adapted to support temporary generation of
sourcemaps, which may become helpful for debugging and development, now
that more variables are being mangled due to the activation of the
terser `module` option.

A sourcemap can be built via:

  npm run build-js -- --sourcemaps

  # Or only build sourcemaps for changed files
  npm run build -- watch --sourcemaps

Please note that the sourcemap is inlined into the source file
and needs to be rebuilt without --sourcemaps enabled in order
to be mergable. (CI will verify)

Asynchronous exection task
--------------------------

The TypeScirpt post-processing-copy task and the terser task are merged
into a new combined asynchronous grunt task, allowing to minify lit html
literals first and apply terser minifcation afterwards.
(Previously terser was executed first and minify-html-literals
afterwards, which worked because terser did not mangle `html`
literals without `module` mode being enabled)

The combined – and most importantly asynchronous – grunt task allows
to perform the switch to cssnano instead of clean-css,
which also requires asynchronous execution.

Terser is updated in order to use latest minifcation routines,
while rebuild most source files anyway:

Commands executed:
  npm remove \
    postcss-clean \
    rollup-plugin-postcss \
    minify-html-literals \
    es-module-lexer
  # Updates
  npm install --save-dev \
    terser@^5.39 \
    rollup@^4.36 \
    @rollup/plugin-commonjs@^28 \
    @rollup/plugin-node-resolve@^16 \
    postcss@^8.5 \
    cssnano@^7 \
    autoprefixer@^10.4.21 \
    litnano@^0.4.0 \
    grunt-sass@v4
  # Update to depend on cssnano v7 instead of v6
  npm install --save-dev @ckeditor/ckeditor5-dev-utils@^46
  npm audit fix
  grep -rl clean-css Build/Sources | xargs sed -i '/clean-css/d'
  npm run build

Review

  • Code review CR 0
  • Verified V 0

Issues 2

Files 467

Show 447 more files

Review log 814

  1. Benjamin Franzke uploaded patch set 1 03/15/25, 08:10

  2. Benjamin Franzke marked it work in progress 03/15/25, 08:10

  3. core-ci voted on patch set 1 V -1 03/15/25, 08:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75640

  4. Benjamin Franzke uploaded patch set 2 V -1 03/15/25, 19:45

  5. core-ci voted on patch set 2 V +1 03/15/25, 19:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75643

  6. Benjamin Franzke uploaded patch set 3 V +1 03/21/25, 20:15

  7. core-ci voted on patch set 3 V +1 03/21/25, 20:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75980

  8. Benjamin Franzke uploaded patch set 4 V +1 03/22/25, 10:35

  9. core-ci voted on patch set 4 V -1 03/22/25, 10:43 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76014

  10. Benjamin Franzke uploaded patch set 5 V -1 03/22/25, 11:00

  11. Benjamin Franzke uploaded patch set 6 03/22/25, 11:02

  12. core-ci voted on patch set 5 V -1 03/22/25, 11:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76015

  13. core-ci voted on patch set 6 V +1 03/22/25, 11:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76016

  14. Benjamin Franzke abandoned the change 03/22/25, 16:04

    merged into parent in relation chain: https://review.typo3.org/c/Packages/TYPO3.CMS/+/88272