denoland / dnt

Deno to npm package build tool.
MIT License
1.21k stars 38 forks source link

Add default node web stream shim #362

Open dsherret opened 7 months ago

dsherret commented 7 months ago

Something like this, but need to actually go through and figure out what everything is based on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/stream/web.d.ts#L17 and https://github.com/denoland/deno/blob/7281775381cda79ef61df27820387dc2c74e0384/ext/web/lib.deno_web.d.ts

// in https://github.com/denoland/dnt/blob/main/lib/shims.ts
function getNodeWebStreamsShim(): Shim {
  return {
    package: {
      name: "node:stream/web",
    },
    globalNames: [
      "ReadableStream",
      "WritableStream",
      "TextDecoderStream",
      typeOnly("ReadableStreamController"),
      typeOnly("ReadableStreamDefaultReadValueResult"),
      typeOnly("ReadableStreamDefaultReader"),
      typeOnly("WritableStreamDefaultWriter"),
      typeOnly("QueuingStrategy"),
      {
        name: "PipeOptions",
        exportName: "StreamPipeOptions",
        typeOnly: true,
      },
    ],
  };
}

Then someone could just do: nodeWebStreams: true in their shims.

seriousme commented 6 months ago

See also: https://nodejs.org/api/webstreams.html#web-streams-api