fix: workaround undefined global this #688
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: the
engine.io.js
file is the generated output ofmake engine.io.js
, and should not be manually modified.The kind of change this PR does introduce
Current behaviour
Default export of
globalThis
seems to have a problemin the "browser" field when the library is loaded asynchronously.
We are using engine.io-client via socket.io-client.
We recently upgraded sockete.io-client from
v3.1.3
tov4.4.1
.And we started seeing the following error:
globalThis
is undefined here:engine.io-client/lib/transports/polling-xhr.ts
Line 315 in 3c40aa9
We've confirmed that the issue started from socket.io-client
v4.3.0
,which is the version where both socket.io-client and engine.io-client
migrated their builds from webpack to rollup.
So we are suspecting it's the compatibility issue of mixing webpack and rollup.
New behaviour
Avoid using default import resolves the issue.
Other information (e.g. related issues)
this might be related:
4971914