Skip to content

Commit

Permalink
Switch back to whatwg-fetch, close pretenderjs#235
Browse files Browse the repository at this point in the history
  • Loading branch information
givanse committed Jan 1, 2019
1 parent 215324d commit ee940f1
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 17 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,21 @@ $.get('/photos/12', {success() => { ... }})
## Usage examples
You can import Pretender as a module or use it directly in the browser.
```javascript
import Pretender from 'pretender';
const server = new Pretender(function() {});
```
```javascript
const Pretender = require('pretender/pretender.cjs.js');
const server = new Pretender(function() {});
```
```javascript
<script src="pretender.js"></script>
```
## The Server DSL
The server DSL is inspired by express/sinatra. Pass a function to the Pretender constructor
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function(config) {
'bower_components/jquery/dist/jquery.js',
'node_modules/es6-promise/dist/es6-promise.auto.js',
'node_modules/abortcontroller-polyfill/dist/abortcontroller-polyfill-only.js',
'node_modules/@xg-wang/whatwg-fetch/dist/fetch.umd.js',
'node_modules/whatwg-fetch/dist/fetch.umd.js',
'pretender.js',
'test/**/*.js'
],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"dependencies": {
"@babel/plugin-external-helpers": "^7.2.0",
"@xg-wang/whatwg-fetch": "^3.0.0",
"whatwg-fetch": "^3.0.0",
"fake-xml-http-request": "^2.0.0",
"route-recognizer": "^0.3.3"
},
Expand All @@ -59,7 +59,7 @@
"deps": [
"route-recognizer",
"fake-xml-http-request",
"@xg-wang/whatwg-fetch"
"whatwg-fetch"
],
"exports": "Pretender"
}
Expand Down
1 change: 0 additions & 1 deletion pretender.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var Pretender = (function (self, RouteRecognizer, FakeXMLHttpRequest, FakeFetch)
self = self && self.hasOwnProperty('default') ? self['default'] : self;
RouteRecognizer = RouteRecognizer && RouteRecognizer.hasOwnProperty('default') ? RouteRecognizer['default'] : RouteRecognizer;
FakeXMLHttpRequest = FakeXMLHttpRequest && FakeXMLHttpRequest.hasOwnProperty('default') ? FakeXMLHttpRequest['default'] : FakeXMLHttpRequest;
FakeFetch = FakeFetch && FakeFetch.hasOwnProperty('default') ? FakeFetch['default'] : FakeFetch;

/**
* parseURL - decompose a URL into its parts
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
input: 'src/index.ts',
external: [
selfId,
'@xg-wang/whatwg-fetch',
'whatwg-fetch',
'fake-xml-http-request',
'route-recognizer',
],
Expand All @@ -20,7 +20,7 @@ module.exports = {
format: 'iife',
globals: {
[selfId]: 'self',
'@xg-wang/whatwg-fetch': 'FakeFetch',
'whatwg-fetch': 'FakeFetch',
'fake-xml-http-request': 'FakeXMLHttpRequest',
'route-recognizer': 'RouteRecognizer',
},
Expand Down
5 changes: 1 addition & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import self from './iife-self-placeholder';
import RouteRecognizer from 'route-recognizer';
import FakeXMLHttpRequest from 'fake-xml-http-request';

// fetch related ponyfills
// TODO: use whatwg-fetch once new version release
import FakeFetch from '@xg-wang/whatwg-fetch';
import * as FakeFetch from 'whatwg-fetch';

/**
* parseURL - decompose a URL into its parts
Expand Down
2 changes: 1 addition & 1 deletion src/pretender.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
var self = _interopDefault(require('./iife-self-placeholder.ts'));
var RouteRecognizer = _interopDefault(require('route-recognizer'));
var FakeXMLHttpRequest = _interopDefault(require('fake-xml-http-request'));
var FakeFetch = _interopDefault(require('@xg-wang/whatwg-fetch'));
var FakeFetch = require('whatwg-fetch');

/**
* parseURL - decompose a URL into its parts
Expand Down
2 changes: 1 addition & 1 deletion src/pretender.es.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import self from './iife-self-placeholder.ts';
import RouteRecognizer from 'route-recognizer';
import FakeXMLHttpRequest from 'fake-xml-http-request';
import FakeFetch from '@xg-wang/whatwg-fetch';
import * as FakeFetch from 'whatwg-fetch';

/**
* parseURL - decompose a URL into its parts
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67"
integrity sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==

"@xg-wang/whatwg-fetch@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@xg-wang/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#f7b222c012a238e7d6e89ed3d72a1e0edb58453d"
integrity sha512-ULtqA6L75RLzTNW68IiOja0XYv4Ebc3OGMzfia1xxSEMpD0mk/pMvkQX0vbCFyQmKc5xGp80Ms2WiSlXLh8hbA==

abbrev@1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
Expand Down Expand Up @@ -4479,6 +4474,11 @@ walker@1.x:
dependencies:
makeerror "1.0.x"

whatwg-fetch@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb"
integrity sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==

which@^1.1.1, which@^1.2.1, which@^1.2.10:
version "1.3.0"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
Expand Down

0 comments on commit ee940f1

Please sign in to comment.