Skip to content

Commit

Permalink
fix: use named export for globalThis shim (#688)
Browse files Browse the repository at this point in the history
Default export of globalThis seems to have a problem in the "browser"
field when the library is loaded asynchronously with webpack.
  • Loading branch information
yujiosaka authored and darrachequesne committed May 2, 2022
1 parent 8437600 commit 32878ea
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/globalThis.browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default (() => {
export const globalThisShim = (() => {
if (typeof self !== "undefined") {
return self;
} else if (typeof window !== "undefined") {
Expand Down
2 changes: 1 addition & 1 deletion lib/globalThis.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default global;
export const globalThisShim = global;
2 changes: 1 addition & 1 deletion lib/transports/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import XMLHttpRequest from "./xmlhttprequest.js";
import { Emitter } from "@socket.io/component-emitter";
import { SocketOptions } from "../socket.js";
import { installTimerFunctions, pick } from "../util.js";
import globalThis from "../globalThis.js";
import { globalThisShim as globalThis } from "../globalThis.js";

const debug = debugModule("engine.io-client:polling"); // debug()

Expand Down
2 changes: 1 addition & 1 deletion lib/transports/websocket-constructor.browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from "../globalThis.js";
import { globalThisShim as globalThis } from "../globalThis.js";

export const nextTick = (() => {
const isPromiseAvailable =
Expand Down
2 changes: 1 addition & 1 deletion lib/transports/xmlhttprequest.browser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// browser shim for xmlhttprequest module

import { hasCORS } from "../contrib/has-cors.js";
import globalThis from "../globalThis.js";
import { globalThisShim as globalThis } from "../globalThis.js";

export default function(opts) {
const xdomain = opts.xdomain;
Expand Down
2 changes: 1 addition & 1 deletion lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from "./globalThis.js";
import { globalThisShim as globalThis } from "./globalThis.js";

export function pick(obj, ...attr) {
return attr.reduce((acc, k) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/xmlhttprequest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// browser shim for xmlhttprequest module

import { hasCORS } from "./contrib/has-cors.js";
import globalThis from "./globalThis.js";
import { globalThisShim as globalThis } from "./globalThis.js";

export default function(opts) {
const xdomain = opts.xdomain;
Expand Down

0 comments on commit 32878ea

Please sign in to comment.