From aa9394781bfc92f8d7c981be7daf8af4b4cd4fae Mon Sep 17 00:00:00 2001 From: Sam Gwilym Date: Wed, 7 Sep 2022 14:51:13 +0000 Subject: [PATCH] Add CommonJS export --- index.node.cjs | 35 +++++++++++++++++++++++++++++++++ index.node.js => index.node.mjs | 0 package.json | 11 ++++++++--- 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 index.node.cjs rename index.node.js => index.node.mjs (100%) diff --git a/index.node.cjs b/index.node.cjs new file mode 100644 index 0000000..1343d9c --- /dev/null +++ b/index.node.cjs @@ -0,0 +1,35 @@ +const { + ReadableStream, + ReadableStreamDefaultReader, + ReadableStreamBYOBReader, + ReadableStreamBYOBRequest, + ReadableByteStreamController, + ReadableStreamDefaultController, + TransformStream, + TransformStreamDefaultController, + WritableStream, + WritableStreamDefaultWriter, + WritableStreamDefaultController, + ByteLengthQueuingStrategy, + CountQueuingStrategy, + TextEncoderStream, + TextDecoderStream, +} = require("node:stream/web"); + +module.exports = { + ReadableStream, + ReadableStreamDefaultReader, + ReadableStreamBYOBReader, + ReadableStreamBYOBRequest, + ReadableByteStreamController, + ReadableStreamDefaultController, + TransformStream, + TransformStreamDefaultController, + WritableStream, + WritableStreamDefaultWriter, + WritableStreamDefaultController, + ByteLengthQueuingStrategy, + CountQueuingStrategy, + TextEncoderStream, + TextDecoderStream, +} \ No newline at end of file diff --git a/index.node.js b/index.node.mjs similarity index 100% rename from index.node.js rename to index.node.mjs diff --git a/package.json b/package.json index a084694..41a86ef 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,16 @@ "name": "isomorphic-streams", "version": "1.0.3", "description": "Isomorphic WHATWG Streams API package for browser and Node.js", - "main": "./index.node.js", + "main": "./index.node.cjs", + "module": "./index.module.mjs", "browser": "./index.browser.js", "types": "./index.d.ts", "exports": { "types": "./index.d.ts", - "node": "./index.node.js", + "node": { + "import": "./index.node.mjs", + "require": "./index.node.cjs" + }, "default": "./index.browser.js" }, "license": "MIT", @@ -47,7 +51,8 @@ "files": [ "index.d.ts", "index.browser.js", - "index.node.js", + "index.node.cjs", + "index.node.mjs", "LICENSE", "README.md" ]