Skip to content

Commit a27fddd

Browse files
authored
Merge branch 'master' into feature/abortable-fetch
2 parents a732db8 + 711c4e9 commit a27fddd

File tree

11 files changed

+116
-9802
lines changed

11 files changed

+116
-9802
lines changed

.babelrc

Lines changed: 0 additions & 18 deletions
This file was deleted.

.browserslistrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22

33
> 1%
44
last 2 versions
5-
ie >= 9

.dist.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
["@babel/env", {
4+
"targets": {
5+
"browsers": [ "> 1%", "last 2 versions" ]
6+
}
7+
}]
8+
],
9+
"plugins": [ "@babel/transform-runtime" ]
10+
}

.dist.eslintrc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"extends": ["eslint:recommended"],
3+
"env": {
4+
"node": true,
5+
"browser": true,
6+
"amd": true,
7+
"es6": true
8+
},
9+
"plugins": ["compat"],
10+
"rules": {
11+
"compat/compat": "error",
12+
"no-func-assign": "off",
13+
"no-redeclare": "off",
14+
"no-console": "off",
15+
"no-constant-condition": "off",
16+
"no-unused-vars": "off",
17+
"no-empty": "off",
18+
"no-useless-escape": "off",
19+
"no-fallthrough": "off",
20+
"getter-return": "off"
21+
},
22+
"globals": {
23+
"regeneratorRuntime": "writable"
24+
},
25+
"settings": {
26+
"polyfills": [
27+
"fetch",
28+
"Promise",
29+
"Symbol",
30+
"Array.from",
31+
"ArrayBuffer.isView",
32+
"Headers",
33+
"Request",
34+
"Response",
35+
"Object.setPrototypeOf",
36+
"Object.getOwnPropertySymbols",
37+
"Uint8Array"
38+
]
39+
}
40+
}

.eslintrc

Lines changed: 0 additions & 22 deletions
This file was deleted.

.lib.babelrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
["@babel/env", {
4+
"targets": {
5+
"node": "6.4.0"
6+
}
7+
}]
8+
]
9+
}

.lib.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": ["eslint:recommended", "plugin:node/recommended"],
3+
"rules": {
4+
"no-unused-vars": "off"
5+
}
6+
}

README.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Modern [fetch-based][fetch] alternative to [axios][]/[superagent][]/[request][].
2626
* [Example](#example)
2727
* [API](#api)
2828
* [Common Issues](#common-issues)
29+
* [Required ES6 Features](#required-es6-features)
2930
* [Frequently Asked Questions](#frequently-asked-questions)
3031
* [How do I unset a default header](#how-do-i-unset-a-default-header)
3132
* [Why do my form uploads randomly fail with React Native](#why-do-my-form-uploads-randomly-fail-with-react-native)
@@ -62,12 +63,10 @@ Modern [fetch-based][fetch] alternative to [axios][]/[superagent][]/[request][].
6263

6364
#### VanillaJS
6465

65-
See [usage example and API below](#usage) for a more complete example.
66+
1. Load the package via `<script>` tag (note you will need to polyfill with [required ES6 features](#required-es6-features)):
6667

6768
```html
68-
<!-- until this PR is merged we will need to use specific path for es6-promise -->
69-
<!-- https://github.com/stefanpenner/es6-promise/pull/343 -->
70-
<script src="https://unpkg.com/es6-promise/dist/es6-promise.auto.min.js"></script>
69+
<script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js?features=fetch%2CPromise%2CSymbol%2CArray.from%2CObject.setPrototypeOf%2CUint8Array"></script>
7170
<script src="https://unpkg.com/frisbee"></script>
7271
<script type="text/javascript">
7372
(function() {
@@ -91,6 +90,8 @@ See [usage example and API below](#usage) for a more complete example.
9190
</script>
9291
```
9392

93+
2. See [usage example and API below](#usage) for a more complete example.
94+
9495
#### Bundler
9596

9697
1. Install the required package:
@@ -99,21 +100,9 @@ See [usage example and API below](#usage) for a more complete example.
99100
npm install frisbee
100101
```
101102

102-
2. (Optional) Install `es6-promise` to polyfill older browsers with `Promise`:
103-
104-
```sh
105-
npm install es6-promise
106-
```
107-
108-
3. (Optional) Ensure that you invoke the polyfill for `es6-promise` if you are using it:
109-
110-
```js
111-
// add optional support for older browsers
112-
const es6promise = require('es6-promise');
113-
es6promise.polyfill();
114-
```
103+
2. Ensure that your environment is polyfilled with [required ES6 features](#required-es6-features) (e.g. use [@babel/polyfill][babel-polyfill] globally or a service like [polyfill.io](https://polyfill.io))
115104

116-
4. See [usage example and API below](#usage)
105+
3. See [usage example and API below](#usage)
117106

118107

119108
## Usage
@@ -323,6 +312,19 @@ Upon being invoked, `Frisbee` returns an object with the following chainable met
323312
* If you're using `node-fetch`, you need `node-fetch@v1.5.3+` to use `form-data` with files properly (due to [bitinn/node-fetch#102](https://github.com/bitinn/node-fetch/issues/102))
324313
* If you experience form file upload issues, please see [facebook/react-native#7564 (comment)](https://github.com/facebook/react-native/issues/7564#issuecomment-266323928).
325314

315+
### Required ES6 Features
316+
317+
This list is sourced from ESLint output and polyfilled settings through [eslint-plugin-compat][].
318+
319+
* `fetch`
320+
* `Promise`
321+
* `Symbol`
322+
* `Array.from`
323+
* `ArrayBuffer.isView`
324+
* `Object.setPrototypeOf`
325+
* `Object.getOwnPropertySymbols`
326+
* `Uint8Array`
327+
326328

327329
## Frequently Asked Questions
328330

@@ -507,3 +509,7 @@ Therefore we created `frisbee` to serve as our API glue, and hopefully it'll ser
507509
[request]: https://github.com/request/request
508510

509511
[fetch-methods]: https://developer.mozilla.org/en-US/docs/Web/API/Body
512+
513+
[babel-polyfill]: https://babeljs.io/docs/en/babel-polyfill
514+
515+
[eslint-plugin-compat]: https://github.com/amilajack/eslint-plugin-compat

package.json

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "frisbee",
33
"description": "Modern fetch-based alternative to axios/superagent/request. Great for React Native.",
4-
"version": "2.0.6",
4+
"version": "2.0.9",
55
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)",
66
"ava": {
77
"failFast": true,
@@ -42,46 +42,43 @@
4242
"abortcontroller-polyfill": "^1.2.4",
4343
"caseless": "^0.12.0",
4444
"common-tags": "^1.8.0",
45-
"cross-fetch": "^3.0.1",
46-
"qs": "^6.6.0",
45+
"cross-fetch": "^3.0.2",
46+
"qs": "^6.7.0",
4747
"url-join": "^4.0.0"
4848
},
4949
"devDependencies": {
50-
"@babel/cli": "^7.2.3",
51-
"@babel/core": "^7.2.2",
52-
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
53-
"@babel/plugin-transform-runtime": "^7.2.0",
54-
"@babel/preset-env": "^7.3.1",
50+
"@babel/cli": "^7.4.4",
51+
"@babel/core": "^7.4.4",
52+
"@babel/plugin-transform-runtime": "^7.4.4",
53+
"@babel/preset-env": "^7.4.4",
5554
"@commitlint/cli": "^7.5.2",
5655
"@commitlint/config-conventional": "^7.5.0",
57-
"ava": "^1.2.1",
56+
"ava": "^1.4.1",
5857
"babelify": "^10.0.0",
59-
"body-parser": "^1.18.3",
58+
"body-parser": "^1.19.0",
6059
"browserify": "^16.2.3",
61-
"caniuse-lite": "^1.0.30000938",
62-
"codecov": "^3.2.0",
60+
"codecov": "^3.3.0",
6361
"cors": "^2.8.5",
6462
"cross-env": "^5.2.0",
65-
"es6-promise": "^4.2.5",
66-
"eslint": "^5.13.0",
63+
"es6-promise": "^4.2.6",
64+
"eslint": "^5.16.0",
6765
"eslint-config-xo-lass": "^1.0.3",
68-
"eslint-plugin-compat": "^2.7.0",
66+
"eslint-plugin-compat": "^3.1.1",
6967
"eslint-plugin-node": "^8.0.1",
7068
"express": "^4.16.4",
7169
"fixpack": "^2.3.1",
72-
"husky": "^1.3.1",
73-
"is-stream": "^1.1.0",
74-
"jsdom": "^13.2.0",
75-
"lint-staged": "^8.1.4",
70+
"husky": "^2.1.0",
71+
"is-stream": "^2.0.0",
72+
"jsdom": "^15.0.0",
73+
"lint-staged": "^8.1.5",
7674
"lodash": "^4.17.11",
77-
"nyc": "^13.3.0",
78-
"prettier": "^1.16.4",
75+
"nyc": "^14.0.0",
7976
"remark-cli": "^6.0.1",
8077
"remark-preset-github": "^0.0.13",
8178
"rimraf": "^2.6.3",
82-
"sinon": "^7.2.3",
79+
"sinon": "^7.3.2",
8380
"tinyify": "^2.5.0",
84-
"uglify-js": "^3.4.9",
81+
"uglify-js": "^3.5.9",
8582
"xo": "0.24.0"
8683
},
8784
"engines": {
@@ -156,14 +153,14 @@
156153
},
157154
"scripts": {
158155
"ava": "cross-env NODE_ENV=test ava",
159-
"browserify": "browserify src/index.js -o dist/frisbee.js -s Frisbee -d -t babelify",
156+
"browserify": "browserify src/index.js -o dist/frisbee.js -s Frisbee -d -t [ babelify --configFile ./.dist.babelrc ]",
160157
"build": "npm run build:clean && npm run build:lib && npm run build:dist",
161158
"build:clean": "rimraf lib dist",
162159
"build:dist": "npm run browserify && npm run minify",
163-
"build:lib": "babel src --out-dir lib",
160+
"build:lib": "babel --config-file ./.lib.babelrc src --out-dir lib",
164161
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
165-
"lint": "xo && remark . -qfo && eslint lib",
166-
"minify": "cross-env NODE_ENV=production browserify src/index.js -o dist/frisbee.min.js -s Frisbee -t babelify -p tinyify",
162+
"lint": "xo && remark . -qfo && eslint -c .lib.eslintrc lib && eslint -c .dist.eslintrc dist",
163+
"minify": "cross-env NODE_ENV=production browserify src/index.js -o dist/frisbee.min.js -s Frisbee -t [ babelify --configFile ./.dist.babelrc ] -p tinyify",
167164
"nyc": "cross-env NODE_ENV=test nyc ava",
168165
"test": "npm run build && npm run lint && npm run ava",
169166
"test-coverage": "npm run build && npm run lint && npm run nyc"

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const caseless = require('caseless');
22
const qs = require('qs');
3-
const fetch = require('cross-fetch');
43
const urlJoin = require('url-join');
54
// eslint-disable-next-line import/no-unassigned-import
65
require('abortcontroller-polyfill/dist/polyfill-patch-fetch');
76

7+
// eslint-disable-next-line import/no-unassigned-import
8+
require('cross-fetch/polyfill');
9+
810
const Interceptor = require('./interceptor');
911

1012
const methods = ['get', 'head', 'post', 'put', 'del', 'options', 'patch'];

0 commit comments

Comments
 (0)