Skip to content

Commit d8bf840

Browse files
talentlessguyfacebook-github-bot
authored andcommitted
Remove unnecessary through2 package (#1430)
Summary: through2 is a legacy dependency and is no longer required. Metro targets Node 18 where Transform streams are stable and do not need a userland package. Changelog: [Internal] Remove unnecessary through2 package Pull Request resolved: #1430 Test Plan: All tests pass on Node 18: <img width="752" alt="Screenshot 2025-01-21 at 00 38 31" src="https://github.com/user-attachments/assets/4c3179a7-7203-41c9-9ed9-e14d83238048" /> Reviewed By: vzaidman Differential Revision: D68437314 Pulled By: robhogan fbshipit-source-id: d70503ad8c5638392b7af883b20a8edd3f7db38b
1 parent 14c4d43 commit d8bf840

File tree

3 files changed

+29
-85
lines changed

3 files changed

+29
-85
lines changed

packages/metro-symbolicate/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"metro-source-map": "0.81.0",
2323
"nullthrows": "^1.1.1",
2424
"source-map": "^0.5.6",
25-
"through2": "^2.0.1",
2625
"vlq": "^1.0.0"
2726
},
2827
"engines": {

packages/metro-symbolicate/src/symbolicate.js

+28-30
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ const Symbolication = require('./Symbolication.js');
2323
const fs = require('fs');
2424
// flowlint-next-line untyped-import:off
2525
const SourceMapConsumer = require('source-map').SourceMapConsumer;
26-
// flowlint-next-line untyped-import:off
27-
const through2 = require('through2');
26+
const {Transform} = require('stream');
2827

2928
function printHelp() {
3029
const usages = [
@@ -167,35 +166,34 @@ async function main(
167166
),
168167
);
169168
} else if (argv[0] === '--attribution') {
170-
let buffer = '';
169+
let lineBuffer = '';
170+
171+
const streamToLines: Transform = new Transform({
172+
transform(data, _enc, callback) {
173+
// Take arbitrary strings, output single lines
174+
lineBuffer += data.toString();
175+
const lines = lineBuffer.split('\n');
176+
for (let i = 0, e = lines.length - 1; i < e; i++) {
177+
streamToLines.push(lines[i]);
178+
}
179+
lineBuffer = lines[lines.length - 1];
180+
callback();
181+
},
182+
});
183+
184+
const symbolicateLines: Transform = new Transform({
185+
transform(data, enc, callback) {
186+
// This is JSONL, so each line is a separate JSON object
187+
const obj = JSON.parse(data.toString());
188+
context.symbolicateAttribution(obj);
189+
symbolicateLines.push(JSON.stringify(obj) + '\n');
190+
callback();
191+
},
192+
objectMode: true,
193+
});
194+
171195
await waitForStream(
172-
stdin
173-
.pipe(
174-
/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s)
175-
* required by Flow's LTI update could not be added via codemod */
176-
through2(function (data, enc, callback) {
177-
// Take arbitrary strings, output single lines
178-
buffer += data;
179-
const lines = buffer.split('\n');
180-
for (let i = 0, e = lines.length - 1; i < e; i++) {
181-
this.push(lines[i]);
182-
}
183-
buffer = lines[lines.length - 1];
184-
callback();
185-
}),
186-
)
187-
.pipe(
188-
/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s)
189-
* required by Flow's LTI update could not be added via codemod */
190-
through2.obj(function (data, enc, callback) {
191-
// This is JSONL, so each line is a separate JSON object
192-
const obj = JSON.parse(data);
193-
context.symbolicateAttribution(obj);
194-
this.push(JSON.stringify(obj) + '\n');
195-
callback();
196-
}),
197-
)
198-
.pipe(stdout),
196+
stdin.pipe(streamToLines).pipe(symbolicateLines).pipe(stdout),
199197
);
200198
} else if (argv[0].endsWith('.cpuprofile')) {
201199
// NOTE: synchronous

yarn.lock

+1-54
Original file line numberDiff line numberDiff line change
@@ -2230,11 +2230,6 @@ core-js-pure@^3.25.1:
22302230
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.26.1.tgz#653f4d7130c427820dcecd3168b594e8bb095a33"
22312231
integrity sha512-VVXcDpp/xJ21KdULRq/lXdLzQAtX7+37LzpyfFM973il0tWSsDEoyzG38G14AjTpK9VTfiNM9jnFauq/CpaWGQ==
22322232

2233-
core-util-is@~1.0.0:
2234-
version "1.0.2"
2235-
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
2236-
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=
2237-
22382233
cosmiconfig@^5.0.5:
22392234
version "5.2.1"
22402235
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.2.1.tgz#040f726809c591e77a17c0a3626ca45b4f168b1a"
@@ -3501,11 +3496,6 @@ is-weakref@^1.0.2:
35013496
dependencies:
35023497
call-bind "^1.0.2"
35033498

3504-
isarray@~1.0.0:
3505-
version "1.0.0"
3506-
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
3507-
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
3508-
35093499
isexe@^2.0.0:
35103500
version "2.0.0"
35113501
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
@@ -4851,11 +4841,6 @@ pretty-format@^29.7.0:
48514841
ansi-styles "^5.0.0"
48524842
react-is "^18.0.0"
48534843

4854-
process-nextick-args@~2.0.0:
4855-
version "2.0.1"
4856-
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
4857-
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
4858-
48594844
progress@^2.0.0:
48604845
version "2.0.3"
48614846
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
@@ -4938,19 +4923,6 @@ [email protected]:
49384923
resolved "https://registry.yarnpkg.com/react/-/react-19.0.0.tgz#6e1969251b9f108870aa4bff37a0ce9ddfaaabdd"
49394924
integrity sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ==
49404925

4941-
readable-stream@~2.3.6:
4942-
version "2.3.7"
4943-
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57"
4944-
integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==
4945-
dependencies:
4946-
core-util-is "~1.0.0"
4947-
inherits "~2.0.3"
4948-
isarray "~1.0.0"
4949-
process-nextick-args "~2.0.0"
4950-
safe-buffer "~5.1.1"
4951-
string_decoder "~1.1.1"
4952-
util-deprecate "~1.0.1"
4953-
49544926
recast@^0.21.0:
49554927
version "0.21.5"
49564928
resolved "https://registry.yarnpkg.com/recast/-/recast-0.21.5.tgz#e8cd22bb51bcd6130e54f87955d33a2b2e57b495"
@@ -5106,7 +5078,7 @@ run-parallel@^1.1.9:
51065078
dependencies:
51075079
queue-microtask "^1.2.2"
51085080

5109-
safe-buffer@~5.1.0, safe-buffer@~5.1.1:
5081+
safe-buffer@~5.1.1:
51105082
version "5.1.2"
51115083
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
51125084
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
@@ -5347,13 +5319,6 @@ string.prototype.trimstart@^1.0.5:
53475319
define-properties "^1.1.4"
53485320
es-abstract "^1.19.5"
53495321

5350-
string_decoder@~1.1.1:
5351-
version "1.1.1"
5352-
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
5353-
integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==
5354-
dependencies:
5355-
safe-buffer "~5.1.0"
5356-
53575322
strip-ansi@^5.2.0:
53585323
version "5.2.0"
53595324
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae"
@@ -5476,14 +5441,6 @@ throat@^5.0.0:
54765441
resolved "https://registry.yarnpkg.com/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b"
54775442
integrity sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==
54785443

5479-
through2@^2.0.1:
5480-
version "2.0.5"
5481-
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd"
5482-
integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==
5483-
dependencies:
5484-
readable-stream "~2.3.6"
5485-
xtend "~4.0.1"
5486-
54875444
"through@>=2.2.7 <3":
54885445
version "2.3.8"
54895446
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
@@ -5634,11 +5591,6 @@ uri-js@^4.2.2:
56345591
dependencies:
56355592
punycode "^2.1.0"
56365593

5637-
util-deprecate@~1.0.1:
5638-
version "1.0.2"
5639-
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
5640-
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
5641-
56425594
56435595
version "1.0.1"
56445596
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
@@ -5736,11 +5688,6 @@ xml@^1.0.1:
57365688
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
57375689
integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==
57385690

5739-
xtend@~4.0.1:
5740-
version "4.0.2"
5741-
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
5742-
integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==
5743-
57445691
y18n@^5.0.5:
57455692
version "5.0.8"
57465693
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"

0 commit comments

Comments
 (0)