Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process.env should not be attached inside window object #2904

Closed
vanbasten17 opened this issue Dec 2, 2020 · 16 comments
Closed

process.env should not be attached inside window object #2904

vanbasten17 opened this issue Dec 2, 2020 · 16 comments

Comments

@vanbasten17
Copy link

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).
@sokra
Copy link
Member

sokra commented Dec 2, 2020

webpack itself doesn't add that.

maybe webpack-dev-server @alexander-akait ?

@vanbasten17
Copy link
Author

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 😊

@alexander-akait
Copy link
Member

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

@alexander-akait alexander-akait transferred this issue from webpack/webpack Dec 3, 2020
@vanbasten17
Copy link
Author

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?

@alexander-akait
Copy link
Member

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

@0es
Copy link

0es commented Jan 4, 2021

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

@fmagaldea
Copy link

Same issue here with latest versions of all webpack - related packages with IE 11, than the one reported on #2918

'Symbol' is undefined

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

@grumd
Copy link

grumd commented Jan 16, 2021

@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

@alexander-akait
Copy link
Member

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

@alexander-akait
Copy link
Member

Fixed #2971, sorry for delay, really many issues

@creage
Copy link

creage commented Feb 8, 2021

@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 😃

@alexander-akait
Copy link
Member

Hope this week

@Jefski14
Copy link

Jefski14 commented Mar 2, 2021

Any news on this?

@alexander-akait
Copy link
Member

WIP on IE 11 compatibility

@flyyang
Copy link

flyyang commented Mar 30, 2021

How about ie 10 ?

@alexander-akait
Copy link
Member

#3129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants