Webpack-dev-server: process.env should not be attached inside window object

Created on 2 Dec 2020  路  16Comments  路  Source: webpack/webpack-dev-server


Bug report




What is the current behavior?
Just setted a set of compilation rules to compile a web project along with webpack-dev-server, here's an example:

function botonicDevConfig(mode) {
  return {
    mode: mode,
    devtool: sourceMap(mode),
    target: 'web',
    entry: path.resolve('webpack-entries', 'dev-entry.js'),
    module: {
      rules: [
        babelLoaderConfig,
        babelLoaderConfig2,
        fileLoaderConfig,
        stylesLoaderConfig,
      ],
    },
    output: {
      filename: 'webchat.botonic.js',
      library: 'Botonic',
      libraryTarget: 'umd',
      libraryExport: 'app',
    },
    resolve: resolveConfig,
    devServer: {
      static: [
        path.join(__dirname, 'dist'),
        path.join(__dirname, 'src', 'nlu', 'models'),
      ],
      liveReload: true,
      historyApiFallback: true,
      hot: true,
    },
    plugins: [
      new HtmlWebpackPlugin({
        template: path.resolve(botonicPath, 'src', 'webchat.template.html'),
        filename: 'index.html',
      }),
      new webpack.HotModuleReplacementPlugin(),
      imageminPlugin,
    ],
  }
}

After running the command webpack serve --env target=dev --mode=development and opening the browser, process object comes inside the definition of window object (attached screenshot), with env set as an empty object. See that I'm not using any kind of Environment or Define Plugin, I don't want to have process defined. In previous versions (webpack 4), this variable was undefined (as far as I understand, this should be the common behavior).
Screenshot 2020-12-02 at 22 25 50

If the current behavior is a bug, please provide the steps to reproduce.
After setting above rules,






What is the expected behavior?
process.env should not be attached by default. It should be enabled (in any case) after using some of the plugins to define env variables.


Other relevant information:
webpack version: 5.9.0
Node.js version: v10.23.0, also tried v12.20.0 with same results.
Operating System: macOS Catalina 10.15.7
Additional tools:

"webpack": "^5.9.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^4.0.0-beta.0" (I needed to update dev server in order to make it work, it seems to be broken with latest v3.11.0).

Most helpful comment

Yep, with this week, I am fully focus on webpack-dev-server, IE 11 will be fixed in the next release

All 16 comments

webpack itself doesn't add that.

maybe webpack-dev-server @alexander-akait ?

Hi @sokra , check the first lines of code of this, I think you are right: https://github.com/webpack/webpack-dev-server/blob/b0161e9852cdf41730e82aa43efe7e88f44a4f9d/client-src/default/index.js.
If you prefer, let's close this one and I will open it in webpack-dev-server. Thanks 馃槉

Yep, @vanbasten17 known but, we are working on it

cool @alexander-akait, let me know if you need feedback after the change. By the way, do you know when will be a stable release for webpack-dev-server v4?

Sorry, no, but I think this month, it is already stable in 99% cases so you can use it

Is there any progress on this issue @alexander-akait
Symbol still report errors on low version terminals #2900

Same issue here with latest versions of all webpack - related packages with IE 11, than the one reported on https://github.com/webpack/webpack-dev-server/issues/2918

'Symbol' is undefined

https://github.com/webpack/webpack-dev-server/blob/master/client-src/transpiled-modules/log.js

@alexander-akait This issue sadly completely blocks IE11. With dev-server 3.11.2 HMR doesn't work (because it requires target: ['web', 'es5']), but with dev-server 4.0.0 beta IE11 doesn't work at all due to Symbol/Object.assign errors.

Just donated some to opencollective, I hope it helps a bit

Yep, with this week, I am fully focus on webpack-dev-server, IE 11 will be fixed in the next release

Fixed https://github.com/webpack/webpack-dev-server/pull/2971, sorry for delay, really many issues

@alexander-akait hey Alex, I've started trying to migrate to W5, but these IE11 (God help it die ASAP!) issues are really blocking for us. Any ETA on this fix published? Beta could also work 馃槂

Hope this week

Any news on this?

WIP on IE 11 compatibility

How about ie 10 ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jack-Works picture Jack-Works  路  3Comments

tulika21-zz picture tulika21-zz  路  3Comments

MJ111 picture MJ111  路  3Comments

StephanBijzitter picture StephanBijzitter  路  3Comments

mischkl picture mischkl  路  3Comments