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

fix: workaround undefined global this #688

Closed
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/transports/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ 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 * as globalThisModule from "../globalThis.js";
const globalThis =
globalThisModule.default ||
((globalThisModule as any) as typeof globalThisModule.default);

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

Expand Down
5 changes: 4 additions & 1 deletion lib/transports/websocket-constructor.browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import globalThis from "../globalThis.js";
import * as globalThisModule from "../globalThis.js";
const globalThis =
globalThisModule.default ||
((globalThisModule as any) as typeof globalThisModule.default);

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

import { hasCORS } from "../contrib/has-cors.js";
import globalThis from "../globalThis.js";
import * as globalThisModule from "../globalThis.js";
const globalThis =
globalThisModule.default ||
((globalThisModule as any) as typeof globalThisModule.default);

export default function(opts) {
const xdomain = opts.xdomain;
Expand Down
5 changes: 4 additions & 1 deletion lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import globalThis from "./globalThis.js";
import * as globalThisModule from "./globalThis.js";
const globalThis =
globalThisModule.default ||
((globalThisModule as any) as typeof globalThisModule.default);

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

import { hasCORS } from "./contrib/has-cors.js";
import globalThis from "./globalThis.js";
import * as globalThisModule from "./globalThis.js";
const globalThis =
globalThisModule.default ||
((globalThisModule as any) as typeof globalThisModule.default);

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