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 dcbc77f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 450 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ $.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
<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
8 changes: 2 additions & 6 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 All @@ -33,10 +33,6 @@ module.exports = {
file: 'src/pretender.es.js',
format: 'es'
},
{
file: 'src/pretender.cjs.js',
format: 'cjs'
},
],
plugins: [
resolve(),
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
Loading

0 comments on commit dcbc77f

Please sign in to comment.