const { BannerPlugin } = require("webpack");
const version = require("../package.json").version;

const banner = `Engine.IO v${version}
(c) 2014-${new Date().getFullYear()} Guillermo Rauch
Released under the MIT License.`;

module.exports = {
  entry: "./lib/index.js",
  output: {
    filename: "engine.io.js",
    library: "eio",
    libraryTarget: "umd",
    // see https://github.com/webpack/webpack/issues/6525
    globalObject: `(() => {
      if (typeof self !== 'undefined') {
          return self;
      } else if (typeof window !== 'undefined') {
          return window;
      } else if (typeof global !== 'undefined') {
          return global;
      } else {
          return Function('return this')();
      }
    })()`
  },
  mode: "development",
  node: false,
  module: {
    rules: [
      {
        test: /\.m?js$/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ["@babel/preset-env"],
            plugins: ["@babel/plugin-transform-object-assign"]
          }
        }
      }
    ]
  },
  plugins: [new BannerPlugin(banner)]
};

@@ -359,380 +359,28 @@
     
-// see https://github.com/webpack/webpack/issues/6525%0A    globalObject: %60(() =%3E %7B%0A      if (typeof self !== 'undefined') %7B%0A          return self;%0A      %7D else if (typeof window !== 'undefined') %7B%0A          return window;%0A      %7D else if (typeof global !== 'undefined') %7B%0A          return global;%0A      %7D else %7B%0A          return Function('return this')();%0A      %7D%0A    %7D)()%60
+globalObject: %22this%22
 %0A  %7D

use globalObject "this" in webpack configuration