diff --git a/ext/node/polyfills/stream.ts b/ext/node/polyfills/stream.ts index dabcb8650d..4fe2c505d7 100644 --- a/ext/node/polyfills/stream.ts +++ b/ext/node/polyfills/stream.ts @@ -173,6 +173,7 @@ export { getDefaultHighWaterMark, PassThrough, pipeline, + promises, Readable, setDefaultHighWaterMark, Stream, diff --git a/tests/unit_node/stream_test.ts b/tests/unit_node/stream_test.ts index 751cb97462..58c03ba5e0 100644 --- a/tests/unit_node/stream_test.ts +++ b/tests/unit_node/stream_test.ts @@ -3,7 +3,12 @@ import { assert, assertEquals } from "@std/assert"; import { fromFileUrl, relative } from "@std/path"; import { finished, pipeline } from "node:stream/promises"; -import { getDefaultHighWaterMark, Stream, Writable } from "node:stream"; +import { + getDefaultHighWaterMark, + promises, + Stream, + Writable, +} from "node:stream"; import { TextEncoderStream } from "node:stream/web"; import { createReadStream, createWriteStream } from "node:fs"; import { EventEmitter } from "node:events"; @@ -78,3 +83,18 @@ Deno.test("Writable toWeb", async () => { await finished(nodeWritable); }); + +// https://github.com/denoland/deno/issues/30423 +Deno.test("exported `promises` from node:stream works", async () => { + const stream = new ReadableStream({ + start(controller) { + controller.enqueue("asd"); + controller.close(); + }, + }); + const promise = promises.finished(stream as unknown as NodeJS.ReadableStream); + for await (const chunk of stream) { + assertEquals(chunk, "asd"); + } + await promise; +}); diff --git a/tools/core_import_map.json b/tools/core_import_map.json index e17f13967f..875b600df8 100644 --- a/tools/core_import_map.json +++ b/tools/core_import_map.json @@ -197,7 +197,7 @@ "ext:deno_node/repl.ts": "../ext/node/polyfills/repl.ts", "node:stream": "../ext/node/polyfills/stream.ts", "node:stream/consumers": "../ext/node/polyfills/stream/consumers.mjs", - "node:stream/promises": "../ext/node/polyfills/stream/promises.mjs", + "node:stream/promises": "../ext/node/polyfills/stream/promises.js", "node:stream/web": "../ext/node/polyfills/stream/web.ts", "node:string_decoder": "../ext/node/polyfills/string_decoder.ts", "node:sys": "../ext/node/polyfills/sys.ts",