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

Vendor whatwg-fetch #295

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 0 additions & 5 deletions iife-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ var Pretender = (function(self) {
? getModuleDefault(require('fake-xml-http-request'))
: self.FakeXMLHttpRequest;

// fetch related ponyfills
var FakeFetch = appearsBrowserified
? getModuleDefault(require('whatwg-fetch'))
: self.WHATWGFetch;

/*==ROLLUP_CONTENT==*/

if (typeof module === 'object') {
Expand Down
1 change: 0 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module.exports = function(config) {
'node_modules/route-recognizer/dist/route-recognizer.js',
'node_modules/es6-promise/dist/es6-promise.auto.js',
'node_modules/abortcontroller-polyfill/dist/abortcontroller-polyfill-only.js',
'node_modules/whatwg-fetch/dist/fetch.umd.js',
'dist/pretender.js',
'test/**/*.js'
],
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
},
"dependencies": {
"fake-xml-http-request": "^2.1.1",
"route-recognizer": "^0.3.3",
"whatwg-fetch": "^3.0.0"
"route-recognizer": "^0.3.3"
},
"files": [
"dist",
Expand All @@ -65,8 +64,7 @@
"pretender": {
"deps": [
"route-recognizer",
"fake-xml-http-request",
"whatwg-fetch"
"fake-xml-http-request"
],
"exports": "Pretender"
}
Expand Down
1 change: 0 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const typescript = require('rollup-plugin-typescript');
const pkg = require('./package.json');
const fs = require('fs');
const globals = {
'whatwg-fetch': 'FakeFetch',
'fake-xml-http-request': 'FakeXMLHttpRequest',
'route-recognizer': 'RouteRecognizer',
'url-parse': 'urlParse'
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FakeXMLHttpRequest from 'fake-xml-http-request';
import * as FakeFetch from 'whatwg-fetch';
import * as FakeFetch from './whatwg-fetch';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need to copy the whole file, external: Object.keys(pkg.dependencies), in rollup config is treating whatwg-fetch as external module, when you remove it from pkg.dependencies it will be imported by rollup.
You will still need whatwg-fetch in dev dependencies to let rollup find the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah. But it would make the next step easier since we can wrap it in a check to see if window exists. Otherwise we’ll need to do what I did in the other PR and bring in cross fetch, I think.

import parseURL from './parse-url';
import Registry from './registry';

Expand Down
Loading