Skip to content

Commit dd61dec

Browse files
committed
fix: make browser.js run natively in browser
1 parent 8d75e66 commit dd61dec

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

browser.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
"use strict";
22

33
// ref: https://github.com/tc39/proposal-global
4-
var getGlobal = function () {
5-
// the only reliable means to get the global object is
6-
// `Function('return this')()`
7-
// However, this causes CSP violations in Chrome apps.
8-
if (typeof self !== 'undefined') { return self; }
9-
if (typeof window !== 'undefined') { return window; }
10-
if (typeof global !== 'undefined') { return global; }
11-
throw new Error('unable to locate global object');
4+
var getGlobal = function() {
5+
// the only reliable means to get the global object is
6+
// `Function('return this')()`
7+
// However, this causes CSP violations in Chrome apps.
8+
if (typeof self !== 'undefined') { return self; }
9+
if (typeof window !== 'undefined') { return window; }
10+
if (typeof global !== 'undefined') { return global; }
11+
throw new Error('unable to locate global object');
1212
}
1313

1414
var globalObject = getGlobal();
1515

16-
module.exports = exports = globalObject.fetch;
16+
export const fetch = globalObject.fetch;
1717

18-
// Needed for TypeScript and Webpack.
19-
if (globalObject.fetch) {
20-
exports.default = globalObject.fetch.bind(globalObject);
21-
}
18+
export default globalObject.fetch.bind(globalObject);
2219

23-
exports.Headers = globalObject.Headers;
24-
exports.Request = globalObject.Request;
25-
exports.Response = globalObject.Response;
20+
export const Headers = globalObject.Headers;
21+
export const Request = globalObject.Request;
22+
export const Response = globalObject.Response;

0 commit comments

Comments
 (0)