const sourceUrl = "https://esm.sh/v96/readable-stream@4.2.0/es2022/readable-stream.js";const header = `// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.// Copyright Joyent and Node contributors. All rights reserved. MIT license.// deno-fmt-ignore-file// deno-lint-ignore-fileimport { nextTick } from "./_next_tick.ts";import { stdio } from "./_process/stdio.mjs";
`;const outputFile = new URL("../_stream.mjs", import.meta.url).pathname;const endMarker = "/* End esm.sh bundle */";
const res = await fetch(sourceUrl);let src = await res.text();
src = src.replaceAll(/import { AbortController as.+?;/g, "");src = src.replaceAll("||__abort_controller$AbortController", "");
src = src.replaceAll(/"\/v\d+\/node_buffer.js"/g, '"./buffer.ts"');src = src.replaceAll(/"\/v\d+\/string_decoder.+?"/g, '"./string_decoder.ts"');src = src.replaceAll(/"\/v\d+\/events@.+?"/g, '"./events.ts"');
src = src.replaceAll( /import __process\$ from "\/v\d+\/process@.+?";/g, "const __process$ = { nextTick, stdio };",);
const current = Deno.readTextFileSync(outputFile);const trailer = current.split(endMarker)[1] ?? "";
src = header + src + endMarker + trailer;
Deno.writeTextFileSync(outputFile, src);