Page MenuHomeDevCentral

Rewrite Gulp builder code as module
Open, HighPublic

Description

gulp-imagemin 8 will require to use ES module syntax.

We can modernize builder script following:

Event Timeline

dereckson triaged this task as High priority.Sep 18 2021, 14:29
dereckson created this task.
dereckson renamed this task from Rewrite Gump builder code as module to Rewrite Gulp builder code as module.Sep 18 2021, 14:35

If the goal is to avoid any security issue, gulp-imagemin last version still has a DoS regexp issue with trim-newline dependency.

As Node 22 supports require for ESM too, at least experimentally, we can also require Node 22+ instead.

Some dependencies are loaded through ESM, like supports-color library directly for Node:

(node:25374) ExperimentalWarning: CommonJS module /opt/homebrew/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /opt/homebrew/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time

In another hand, see also Gulp documentation: https://gulpjs.com/docs/en/getting-started/javascript-and-gulpfiles/

They recommend to install esm module to get import/export, instead of babel/@register.