Merge pull request #18113 from timvandermeij/through2

Remove the `through2` dependency in favor of the built-in Node.js `stream.Transform`
This commit is contained in:
Tim van der Meij 2024-05-21 14:20:14 +02:00 committed by GitHub
commit 8753bd9b99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 33 deletions

View File

@ -38,7 +38,6 @@ import replace from "gulp-replace";
import stream from "stream"; import stream from "stream";
import streamqueue from "streamqueue"; import streamqueue from "streamqueue";
import TerserPlugin from "terser-webpack-plugin"; import TerserPlugin from "terser-webpack-plugin";
import through from "through2";
import Vinyl from "vinyl"; import Vinyl from "vinyl";
import webpack2 from "webpack"; import webpack2 from "webpack";
import webpackStream from "webpack-stream"; import webpackStream from "webpack-stream";
@ -119,13 +118,16 @@ const DEFINES = Object.freeze({
}); });
function transform(charEncoding, transformFunction) { function transform(charEncoding, transformFunction) {
return through.obj(function (vinylFile, enc, done) { return new stream.Transform({
const transformedFile = vinylFile.clone(); objectMode: true,
transformedFile.contents = Buffer.from( transform(vinylFile, enc, done) {
transformFunction(transformedFile.contents), const transformedFile = vinylFile.clone();
charEncoding transformedFile.contents = Buffer.from(
); transformFunction(transformedFile.contents),
done(null, transformedFile); charEncoding
);
done(null, transformedFile);
},
}); });
} }

24
package-lock.json generated
View File

@ -56,7 +56,6 @@
"stylelint": "^16.5.0", "stylelint": "^16.5.0",
"stylelint-prettier": "^5.0.0", "stylelint-prettier": "^5.0.0",
"terser-webpack-plugin": "^5.3.10", "terser-webpack-plugin": "^5.3.10",
"through2": "^4.0.2",
"tsc-alias": "^1.8.10", "tsc-alias": "^1.8.10",
"ttest": "^4.0.0", "ttest": "^4.0.0",
"typescript": "^5.4.5", "typescript": "^5.4.5",
@ -20076,15 +20075,6 @@
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
"dev": true "dev": true
}, },
"node_modules/through2": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/through2/-/through2-4.0.2.tgz",
"integrity": "sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==",
"dev": true,
"dependencies": {
"readable-stream": "3"
}
},
"node_modules/through2-filter": { "node_modules/through2-filter": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/through2-filter/-/through2-filter-3.0.0.tgz", "resolved": "https://registry.npmjs.org/through2-filter/-/through2-filter-3.0.0.tgz",
@ -20105,20 +20095,6 @@
"xtend": "~4.0.1" "xtend": "~4.0.1"
} }
}, },
"node_modules/through2/node_modules/readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"dev": true,
"dependencies": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/time-stamp": { "node_modules/time-stamp": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz",

View File

@ -50,7 +50,6 @@
"stylelint": "^16.5.0", "stylelint": "^16.5.0",
"stylelint-prettier": "^5.0.0", "stylelint-prettier": "^5.0.0",
"terser-webpack-plugin": "^5.3.10", "terser-webpack-plugin": "^5.3.10",
"through2": "^4.0.2",
"tsc-alias": "^1.8.10", "tsc-alias": "^1.8.10",
"ttest": "^4.0.0", "ttest": "^4.0.0",
"typescript": "^5.4.5", "typescript": "^5.4.5",