From 69214b1e293a12ed9ad6ad10285fceabcb9cfee7 Mon Sep 17 00:00:00 2001 From: sunrise30 Date: Wed, 28 Nov 2018 22:48:12 +0100 Subject: [PATCH] [fix] Remove any reference to the `global` variable Related: https://github.com/socketio/socket.io-client/issues/1166 --- .eslintrc.json | 3 ++- lib/url.js | 2 +- support/webpack.config.dev.js | 6 +++--- support/webpack.config.slim.dev.js | 9 ++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1e8ee73..3cc4c32 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,7 +3,8 @@ "parser": "babel-eslint", "env": { // Note: mocha env is defined inside test/.eslintrc.json - "node": true + "node": true, + "browser": true }, "rules": { "yoda": 0, diff --git a/lib/url.js b/lib/url.js index 8bac542..1b51c3c 100644 --- a/lib/url.js +++ b/lib/url.js @@ -25,7 +25,7 @@ function url (uri, loc) { var obj = uri; // default to window.location - loc = loc || global.location; + loc = loc || (typeof location !== 'undefined' && location); if (null == uri) uri = loc.protocol + '//' + loc.host; // relative path support diff --git a/support/webpack.config.dev.js b/support/webpack.config.dev.js index a42e186..6c351f0 100644 --- a/support/webpack.config.dev.js +++ b/support/webpack.config.dev.js @@ -10,6 +10,9 @@ module.exports = { externals: { global: glob() }, + node: { + Buffer: false + }, devtool: 'source-map', module: { loaders: [{ @@ -17,9 +20,6 @@ module.exports = { exclude: /(node_modules|bower_components)/, loader: 'babel-loader', query: { presets: ['es2015'] } - }, { - test: /\json3.js/, - loader: 'imports?define=>false' }] } }; diff --git a/support/webpack.config.slim.dev.js b/support/webpack.config.slim.dev.js index 14b04b1..51ed5c7 100644 --- a/support/webpack.config.slim.dev.js +++ b/support/webpack.config.slim.dev.js @@ -10,8 +10,10 @@ module.exports = { filename: 'socket.io.slim.dev.js' }, externals: { - global: glob(), - json3: 'JSON' + global: glob() + }, + node: { + Buffer: false }, devtool: 'source-map', plugins: [ @@ -23,9 +25,6 @@ module.exports = { exclude: /(node_modules|bower_components)/, loader: 'babel-loader', query: { presets: ['es2015'] } - }, { - test: /\json3.js/, - loader: 'imports?define=>false' }, { test: /\.js$/, loader: 'strip-loader?strip[]=debug'