opened
hmnd
username_0
<!--
  Please note that this template is not optional.
  Please fill out _ALL_ fields, or your issue may be closed as "invalid."
  Please do not delete this template.
  Please ask questions on StackOverflow or Gitter (https://gitter.im/webpack/webpack).
  General questions, how-to questions, and support requests will be closed.
-->

- Operating System: Solus
- Node Version: 12.18.0
- NPM Version: 6.14.5
- webpack Version: 5.0.0-beta.18
- webpack-dev-server Version: 3.11.0
- Browser: Firefox Developer Edition 78.0b9

<!--
  Please place an x, no spaces, in all [ ] that apply
  Please note that we are NOT accepting FEATURE requests at this time.
-->

- [x] This is a **bug**
- [ ] This is a **modification** request

### Code

<!--
  If you have a large amount of code to share which demonstrates the problem
  you're experiencing, or your webpack config is very large, please provide a link
  to your repository rather than pasting code. We'd also encourage you to use a
  Github Gist link instead of pasting code. Otherwise, please paste relevant
  short snippets below.

  For bugs, please do consider providing a link to a stripped-down, bare-bones
  repo that can reproduce the problem you're experiencing. Many times, bugs
  aren't actual bugs, but rather specific issues with loaders, plugins, or
  an environment/OS. Problems with complicated or large applications will almost
  always require this to be triaged.
-->

```js
// webpack.config.js
function genConfig(target, name) {
  const config = {
    mode: 'production',
    entry: combinedPaths,
    output: {
      path: buildPath,
      filename: `[name]${
        !target || target === 'window' ? '' : `.${target}`
      }.min.js`,
      libraryTarget: target,
    },
    externals: {
      _: '_',
    },
    module: {
      rules: [
        ...
      ],
    },
    plugins: [
      ...
    ],
    resolve: {
      alias: {
        vue$: 'vue/dist/vue.esm.js',
        '@': path.resolve(__dirname, 'src'),
        path: 'path-browserify',
        stream: 'stream-browserify',
      },
      extensions: ['.ts', '.js', '.vue'],
    },
    optimization: {
      ...
    },
    devServer: {
      host: 'localhost',
      port: 8080,
      https: true,
      headers: {
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Methods':
          'GET, POST, PUT, DELETE, PATCH, OPTIONS',
        'Access-Control-Allow-Headers':
          'X-Requested-With, content-type, Authorization',
      },
      disableHostCheck: true,
      compress: true,
    },
  };
  if (name) {
    config.output.library = name;
  }
  return config;
}

module.exports = [genConfig('window'), genConfig('umd', 'MyLibrary')];
```

### Expected Behavior
Functions are assigned to the `window` object when using dev-server.

### Actual Behavior
Functions are not assigned to the `window` object.

### For Bugs; How can we reproduce the behavior?
Set `libraryTarget` to `window` with no `library` name specified.
Global window libraryTarget does not work with webpack 5
issue
created
evilebottnawi
username_1
What is the problem? We bundle the client before include it. Yes, it is not respect `libraryTarget` and should not
comment
created
hmnd
username_0
@username_1 maybe I'm misunderstanding something, but as far as I can tell, it did work with webpack 4. I develop a library that is embedded in a third-party platform using a script tag. I provide a version of this library exported as a global to `window` to retain backwards compatibility for some of my clients, and I would like those functions to continue to work while I develop them.
comment
created
evilebottnawi
username_1
@username_0 how it is related to webpack-dev-server? We don't modify `libraryTarget`, without webpack-dev-server all works fine?
comment
created
zhangwilling
username_2
But actually it happened . it is very stranrgely, i found when `hot` is enabled, outout.libraryTarget would not works，an empty object will be exported no matter which libraryTarget is setted.

it may caused by webpack5 see [here ](https://github.com/webpack/changelog-v5#hot-module-replacement)

i would do some research to find the answer.
comment
created
zhangwilling
username_2
aha, look this [issue](https://github.com/webpack/webpack-dev-server/issues/2484)
comment
created
evilebottnawi
username_1
Yep, duplicate, let's close in favor https://github.com/webpack/webpack-dev-server/issues/2484
comment
closed
evilebottnawi
username_1
issue