Skip to content

Commit

Permalink
fix: fix usage with vite
Browse files Browse the repository at this point in the history
It seems vite has issues with absolute dependencies in the "browser"
field, so we'll provide a quick workaround.

Backported from 4971914

Related: socketio/socket.io-client#1549
  • Loading branch information
darrachequesne committed Sep 7, 2022
1 parent 6bf9dd6 commit 280de36
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/transports/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Module dependencies
*/

var XMLHttpRequest = require('xmlhttprequest-ssl');
var XMLHttpRequest = require('./xmlhttprequest');
var XHR = require('./polling-xhr');
var JSONP = require('./polling-jsonp');
var websocket = require('./websocket');
Expand Down
2 changes: 1 addition & 1 deletion lib/transports/polling-xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Module requirements.
*/

var XMLHttpRequest = require('xmlhttprequest-ssl');
var XMLHttpRequest = require('./xmlhttprequest');
var Polling = require('./polling');
var Emitter = require('component-emitter');
var inherit = require('component-inherit');
Expand Down
2 changes: 1 addition & 1 deletion lib/transports/polling.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = Polling;
*/

var hasXHR2 = (function () {
var XMLHttpRequest = require('xmlhttprequest-ssl');
var XMLHttpRequest = require('./xmlhttprequest');
var xhr = new XMLHttpRequest({ xdomain: false });
return null != xhr.responseType;
})();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// browser shim for xmlhttprequest module

var hasCORS = require('has-cors');
var globalThis = require('./globalThis');
var globalThis = require('../globalThis');

module.exports = function (opts) {
var xdomain = opts.xdomain;
Expand Down
1 change: 1 addition & 0 deletions lib/transports/xmlhttprequest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('xmlhttprequest-ssl');
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
},
"browser": {
"ws": false,
"xmlhttprequest-ssl": "./lib/xmlhttprequest.js",
"./lib/transports/xmlhttprequest.js": "./lib/transports/xmlhttprequest.browser.js",
"./lib/globalThis.js": "./lib/globalThis.browser.js"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion test/xmlhttprequest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var expect = require('expect.js');
var XMLHttpRequest = require('../lib/xmlhttprequest');
var XMLHttpRequest = require('../lib/transports/xmlhttprequest');
var env = require('./support/env');

describe('XMLHttpRequest', function () {
Expand Down

0 comments on commit 280de36

Please sign in to comment.