From 61afc5d8cb9f10985930b2f01758089c49f84686 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Tue, 2 Feb 2021 11:30:52 +0100 Subject: [PATCH] fix: remove polyfill for process in the bundle A polyfill for Node.js "process" was included in the final bundle. Reference: https://webpack.js.org/configuration/node/ --- support/webpack.config.js | 4 +--- test/index.js | 6 +++--- test/support/env.js | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/support/webpack.config.js b/support/webpack.config.js index 4ba3ab616..82c86a3c5 100644 --- a/support/webpack.config.js +++ b/support/webpack.config.js @@ -14,9 +14,7 @@ module.exports = { }, mode: "development", devtool: "source-map", - node: { - Buffer: false, - }, + node: false, module: { rules: [ { diff --git a/test/index.js b/test/index.js index 24113d388..daeebf67a 100644 --- a/test/index.js +++ b/test/index.js @@ -1,8 +1,8 @@ -require("./support/env"); +const { browser } = require("./support/env"); // whitelist some globals to avoid warnings -if (global.mocha) { - global.mocha.globals(["___eio", "eio_iframe_*"]); +if (browser) { + window.mocha.globals(["___eio", "eio_iframe_*"]); } require("./url.ts"); diff --git a/test/support/env.js b/test/support/env.js index 4c111945c..824d13f9d 100644 --- a/test/support/env.js +++ b/test/support/env.js @@ -2,10 +2,10 @@ // we only do this in our tests because we need to test engine.io-client // support in browsers and in node.js // some tests do not yet work in both -exports.browser = !!global.window; +exports.browser = typeof window !== "undefined"; exports.node = !exports.browser; -if (!global.location) { +if (exports.node) { global.location = { protocol: "http:", host: "localhost:3210",