Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Node.js 12.20.0 and move to ESM #1141

Merged
merged 47 commits into from
Jul 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9d37412
Use ESM import in runkit example file
xxczaki May 3, 2021
ce6d0b2
Update dependencies, version and transition to ESM
xxczaki May 3, 2021
c00d18e
Use ESM imports, add ESM-related info
xxczaki May 3, 2021
73a2a03
Remove rollup
xxczaki May 3, 2021
a12c148
Lint TypeScript-related files
xxczaki May 3, 2021
5ad707e
Update dependency
xxczaki May 3, 2021
efd811d
Lint & update dependency
xxczaki May 3, 2021
42ae6d7
Lint
xxczaki May 3, 2021
dfbb45f
Remove commonjs tests
xxczaki May 3, 2021
d1e0e5e
chore: update changelog
xxczaki May 3, 2021
3e80f90
Remove commonjs GitHub action
xxczaki May 3, 2021
c4018af
Update funding.yml
xxczaki May 3, 2021
75f3e9d
Update linter rules
xxczaki May 5, 2021
eb0426a
Lint
xxczaki May 5, 2021
57f3f2a
Fix tsd
xxczaki May 5, 2021
1305178
Remove unnecessary types
xxczaki May 5, 2021
659044e
Simplify
xxczaki May 5, 2021
cb63877
Use top-level await
xxczaki May 19, 2021
c11eefb
Update GitHub Actions
xxczaki May 19, 2021
a43fe25
Use Mocha with ESM
xxczaki May 19, 2021
4d794ca
Revamp
xxczaki May 19, 2021
94755a8
specify what node version
jimmywarting May 25, 2021
ca4f4cf
update formdata-node dep
jimmywarting May 25, 2021
c2814ad
remove lint from example using top await
jimmywarting May 25, 2021
48bdd14
updated name and link to formdata-polyfill
jimmywarting May 25, 2021
a30a6ee
Stop recommend form-data
jimmywarting May 25, 2021
09deb1e
filter example - it has many duplicate variables
jimmywarting May 25, 2021
f0a6287
Update type definitions to ESM
LinusU May 25, 2021
1c4d1ac
Remove unused lint rule disable comment
LinusU May 25, 2021
10228a9
Remove leftover rollup and dist folder
LinusU May 25, 2021
653ddae
updated depn
jimmywarting May 29, 2021
dc992a3
updated d.ts
jimmywarting May 29, 2021
b80842b
lint
jimmywarting May 29, 2021
fd39435
Fix breaking changes with blob v3 stream()
jimmywarting Jun 12, 2021
d50ad4a
revert eslint comment
jimmywarting Jun 12, 2021
3f94ba7
revert back to xo 0.39
jimmywarting Jun 12, 2021
370a111
none TS fan trying to fix type definition
jimmywarting Jun 12, 2021
930c018
Give me a break
jimmywarting Jun 12, 2021
44c899f
Test on all minimum supported Node.js versions (#1170)
LinusU Jul 16, 2021
ca5e8b7
bumped fetch-blob version
jimmywarting Jul 16, 2021
83b4565
import from dom lib
jimmywarting Jul 16, 2021
74e7d3a
rm unused comment
jimmywarting Jul 16, 2021
aba6a61
updated required version in docs
jimmywarting Jul 16, 2021
e92f07f
fixed named import
jimmywarting Jul 16, 2021
0ae7ecb
set lowest support to 12.20.0
jimmywarting Jul 16, 2021
0ff6298
comment explaining both
jimmywarting Jul 16, 2021
5f0500d
rm log
jimmywarting Jul 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: node-fetch # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: node-fetch # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
37 changes: 6 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,27 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
node: ["14", "12", engines]
node: ["12.20.0", "14.13.1", "16.0.0"]
exclude:
# On Windows, run tests with only the LTS environments.
- os: windows-latest
node: engines
node: "12.22.3"
- os: windows-latest
node: "14"
node: "16.0.0"
# On macOS, run tests with only the LTS environments.
- os: macOS-latest
node: engines
node: "12.22.3"
- os: macOS-latest
node: "14"
node: "16.0.0"

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Get Node.JS version from package.json
if: matrix.node == 'engines'
id: get-version
run: echo ::set-output name=node::$(npx --q minimum-node-version)

- uses: actions/setup-node@v2-beta
if: matrix.node != 'engines'
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- uses: actions/setup-node@v2-beta
if: matrix.node == 'engines'
with:
node-version: ${{steps.get-version.outputs.node}}

- run: npm install

- run: npm test -- --colors
if: matrix.node != 'engines'

- name: Test without coverage
if: matrix.node == 'engines'
run: |
npm i esm
npx mocha -r esm --colors

# upload coverage only once
- name: Coveralls
uses: coverallsapp/github-action@master
if: matrix.node == '12' && matrix.os == 'ubuntu-latest'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
30 changes: 0 additions & 30 deletions .github/workflows/commonjs.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2-beta
uses: actions/setup-node@v2
with:
node-version: 14
- run: npm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
- uses: actions/setup-node@v2

- run: npm install

Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Sketch temporary file
~*.sketch

# Generated files
dist/

# Logs
logs
*.log
Expand Down
77 changes: 24 additions & 53 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/// <reference types="node" />
/// <reference lib="dom" />
jimmywarting marked this conversation as resolved.
Show resolved Hide resolved

/* eslint-disable no-var, import/no-mutable-exports */

import { Agent } from 'http';
import { URL, URLSearchParams } from 'url'
import Blob = require('fetch-blob');
import {Agent} from 'http';

type AbortSignal = {
readonly aborted: boolean;

addEventListener(type: "abort", listener: (this: AbortSignal) => void): void;
removeEventListener(type: "abort", listener: (this: AbortSignal) => void): void;
addEventListener: (type: 'abort', listener: (this: AbortSignal) => void) => void;
removeEventListener: (type: 'abort', listener: (this: AbortSignal) => void) => void;
};

type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>;
export type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>;

/**
* This Fetch API interface allows you to perform various actions on HTTP request and response headers.
Expand All @@ -22,7 +19,7 @@ type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string,
* You can add to this using methods like append() (see Examples.)
* In all methods of this interface, header names are matched by case-insensitive byte sequence.
* */
declare class Headers {
export class Headers {
constructor(init?: HeadersInit);

append(name: string, value: string): void;
Expand Down Expand Up @@ -53,7 +50,7 @@ declare class Headers {
raw(): Record<string, string[]>;
}

interface RequestInit {
export interface RequestInit {
/**
* A BodyInit object or null to set request's body.
*/
Expand Down Expand Up @@ -88,21 +85,20 @@ interface RequestInit {
insecureHTTPParser?: boolean;
}

interface ResponseInit {
export interface ResponseInit {
headers?: HeadersInit;
status?: number;
statusText?: string;
}

type BodyInit =
export type BodyInit =
| Blob
| Buffer
| URLSearchParams
| NodeJS.ReadableStream
| string;
type BodyType = { [K in keyof Body]: Body[K] };
declare class Body {
constructor(body?: BodyInit, opts?: { size?: number });
declare class BodyMixin {
constructor(body?: BodyInit, options?: {size?: number});

readonly body: NodeJS.ReadableStream | null;
readonly bodyUsed: boolean;
Expand All @@ -115,9 +111,12 @@ declare class Body {
text(): Promise<string>;
}

type RequestRedirect = 'error' | 'follow' | 'manual';
type RequestInfo = string | Body;
declare class Request extends Body {
// `Body` must not be exported as a class since it's not exported from the JavaScript code.
export interface Body extends Pick<BodyMixin, keyof BodyMixin> {}

export type RequestRedirect = 'error' | 'follow' | 'manual';
export type RequestInfo = string | Request;
export class Request extends BodyMixin {
constructor(input: RequestInfo, init?: RequestInit);

/**
Expand All @@ -143,9 +142,9 @@ declare class Request extends Body {
clone(): Request;
}

type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"
type ResponseType = 'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect';

declare class Response extends Body {
export class Response extends BodyMixin {
constructor(body?: BodyInit | null, init?: ResponseInit);

readonly headers: Headers;
Expand All @@ -160,8 +159,8 @@ declare class Response extends Body {
static error(): Response;
}

declare class FetchError extends Error {
constructor(message: string, type: string, systemError?: object);
export class FetchError extends Error {
constructor(message: string, type: string, systemError?: Record<string, unknown>);

name: 'FetchError';
[Symbol.toStringTag]: 'FetchError';
Expand All @@ -170,39 +169,11 @@ declare class FetchError extends Error {
errno?: string;
}

declare class AbortError extends Error {
export class AbortError extends Error {
type: string;
name: 'AbortError';
[Symbol.toStringTag]: 'AbortError';
}


declare function fetch(url: RequestInfo, init?: RequestInit): Promise<Response>;
declare class fetch {
static default: typeof fetch;
}
LinusU marked this conversation as resolved.
Show resolved Hide resolved
declare namespace fetch {
export function isRedirect(code: number): boolean;

export {
HeadersInit,
Headers,

RequestInit,
RequestRedirect,
RequestInfo,
Request,

BodyInit,

ResponseInit,
Response,

FetchError,
AbortError
};

export interface Body extends BodyType { }
}

export = fetch;
export function isRedirect(code: number): boolean;
export default function fetch(url: RequestInfo, init?: RequestInit): Promise<Response>;
Loading