Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the
though2
dependency in favor of the built-in Node.js `str…
…eam.Transform` The `though2` dependency got introduced over four years ago in #11325 to replace the unmaintained `gulp-transform` dependency. However, sadly the same holds for `through2` since the last release was also four years ago. Fortunately the `through2` dependency can trivially be replaced with the built-in Node.js `stream.Transform` API nowadays. In fact, the `through2` dependency mentions themselves in their README already that they are "a tiny wrapper around Node.js streams.Transform". The `stream.Transform` API is available in all Node.js versions we support, and in Node.js 6 already the simplified constructor approach for `stream.Transform` got introduced to simplify creating custom stream transformers; see https://nodejs.org/docs/latest-v6.x/api/stream.html#stream_new_stream_transform_options. This commit therefore replaces `through2` by switching to the `stream.Transform` API directly so we don't need any wrappers anymore. Note that for our case the only change we have to make is to enable object mode, see https://nodejs.org/api/stream.html#object-mode, because we pass in `VinylFile` objects instead of e.g. regular `Buffer` objects. I have confirmed in two ways that this is indeed a drop-in replacement: - Running the Gulp targets that call the `transform` function and diffing the resulting `build` folder before/after this patch, with `diff -r build-old/ build-new/`, to ensure that there are no unexpected changes in the output. - Changing the Gulpfile to, instead of UTF-8, transform the files to ASCII, and diffing the resulting `build` folder to confirm that the transformation logic works and produces different results, such as: ``` diff build/lib/core/standard_fonts.js build-ascii/lib/core/standard_fonts.js 284c284 < t["Trinité"] = true; --- > t["Trinit�"] = true; ```
- Loading branch information