From d93512146c35ae3f1c0edc856034b08edac9273d Mon Sep 17 00:00:00 2001 From: David Frank Date: Mon, 5 Nov 2018 15:02:39 +0800 Subject: [PATCH] fix import rule for stream PassThrough --- CHANGELOG.md | 4 ++++ src/index.js | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f321e0ee9..7618670dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ Changelog # 2.x release +## master + +- Fix: `import` on index.js, where `PassThrough` doesn't have a named export when using with node <10 and `--exerimental-modules` flag. + ## v2.2.0 - Enhance: Support all `ArrayBuffer` view types diff --git a/src/index.js b/src/index.js index fa485e42a..53289a1fb 100644 --- a/src/index.js +++ b/src/index.js @@ -11,7 +11,7 @@ import { resolve as resolve_url } from 'url'; import http from 'http'; import https from 'https'; import zlib from 'zlib'; -import { PassThrough } from 'stream'; +import Stream from 'stream'; import Body, { writeToStream, getTotalBytes } from './body'; import Response from './response'; @@ -19,6 +19,9 @@ import Headers, { createHeadersLenient } from './headers'; import Request, { getNodeRequestOptions } from './request'; import FetchError from './fetch-error'; +// fix an issue where PassThrough isn't a named export for node <10 +const PassThrough = Stream.PassThrough; + /** * Fetch function *