Skip to content

Commit 32878ea

Browse files
yujiosakadarrachequesne
yujiosaka
authored andcommitted
fix: use named export for globalThis shim (#688)
Default export of globalThis seems to have a problem in the "browser" field when the library is loaded asynchronously with webpack.
1 parent 8437600 commit 32878ea

7 files changed

+7
-7
lines changed

lib/globalThis.browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default (() => {
1+
export const globalThisShim = (() => {
22
if (typeof self !== "undefined") {
33
return self;
44
} else if (typeof window !== "undefined") {

lib/globalThis.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default global;
1+
export const globalThisShim = global;

lib/transports/polling.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import XMLHttpRequest from "./xmlhttprequest.js";
77
import { Emitter } from "@socket.io/component-emitter";
88
import { SocketOptions } from "../socket.js";
99
import { installTimerFunctions, pick } from "../util.js";
10-
import globalThis from "../globalThis.js";
10+
import { globalThisShim as globalThis } from "../globalThis.js";
1111

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

lib/transports/websocket-constructor.browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import globalThis from "../globalThis.js";
1+
import { globalThisShim as globalThis } from "../globalThis.js";
22

33
export const nextTick = (() => {
44
const isPromiseAvailable =

lib/transports/xmlhttprequest.browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// browser shim for xmlhttprequest module
22

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

66
export default function(opts) {
77
const xdomain = opts.xdomain;

lib/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import globalThis from "./globalThis.js";
1+
import { globalThisShim as globalThis } from "./globalThis.js";
22

33
export function pick(obj, ...attr) {
44
return attr.reduce((acc, k) => {

lib/xmlhttprequest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// browser shim for xmlhttprequest module
22

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

66
export default function(opts) {
77
const xdomain = opts.xdomain;

0 commit comments

Comments
 (0)