Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Multiple Entrypoints with HtmlWebpackPlugin #53

Closed
2 of 3 tasks
shellscape opened this issue May 1, 2018 · 1 comment
Closed
2 of 3 tasks

Multiple Entrypoints with HtmlWebpackPlugin #53

shellscape opened this issue May 1, 2018 · 1 comment

Comments

@shellscape
Copy link
Contributor

  • Operating System: all
  • Node Version: all
  • NPM Version: all
  • webpack Version: 4.6.0
  • webpack-hot-client Version: 2.2.2
  • This is a bug
  • This is a feature request
  • This is a modification request

Code

  // webpack.config.js
{
  entry: {
    main: ['zone.js/dist/zone', './src/main.ts'],
    styles: ['./src/styles.scss', './src/theme.scss'],
    polyfills: ['./src/polyfills.ts'],
    scripts: ['./node_modules/hammerjs/hammer.min.js'],
  },
}

Expected Behavior

In this scenario, hot-client is applying the client entry to each of the entries listed here. In a multi-page scenario, where only one entry per page is being loaded, this is acceptable. In a MultiCompiler scenario this is acceptable.

Actual Behavior

In a scenario where html-webpack-plugin is being used to combine all entries into a single html file for single-page applications, this will cause unwanted side effects:

  • The client entries is applied to all entry compilations, resulting in each entry script on the same page vying for control of the page.
  • Multiple client WebSockets will be created on the same page.

For Bugs; How can we reproduce the behavior?

For Features; What is the motivation and/or use-case for the feature?

We need some kind of mechanism to combat this and configure things correctly for each scenario. There are also going to be exceptions, where for some reason someone will want what is normally incorrect behavior. We also need to be opinionated on what the default behavior is.

This will be a breaking change.

Default

The client entry should only be added to the first config entry of any type of compilation - single or multi.

For a MultiCompiler config the client should only be added to the first entry of the first compilation config. Not sure in which scenarios this is needed.

Introduce autoEntry: false option to disable automatic injection of the client and HotModuleReplacementPlugin so users can manually configure their compilers as needed.

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

No branches or pull requests

1 participant