webpack.js.org icon indicating copy to clipboard operation
webpack.js.org copied to clipboard

The behavior of `entry is array` should be described more specifically

Open Jiang-Xuan opened this issue 5 years ago • 5 comments

Feature request

What is the expected behavior?

The behavior of entry is array should be described more specifically

image

What is motivation or use case for adding/changing the behavior?

When the user sees the document, it should be clear how to use it and what the usage scenario is.

How should this be implemented in your opinion?

I think the document should be like this:

Array Syntax

module.exports = {
  entry: {
    main: ['react', 'react-dom']
  }
};

What happens when you pass an array to entry? Passing an array of file paths to the entry property creates what is known as a "multi-main entry". This is useful when you would like to inject multiple dependent files together and graph their dependencies into one "chunk".

another usage scenario is when you want inject a pollyfill or some special code, you can use array entry instead of import by hand.

example 1:

module.exports = {
  entry: {
    // have not to do `import('@babel/polyfill')` in entry.js file
    main: ['@babel/polyfill', './entry.js']
  }
};

example 2:

Common development environment configuration

module.exports = {
  entry: {
    // inject hot reload code
    main: ['webpack-dev-server/client?https://localhost:8080/', 'webpack/hot/dev-server', './entry.js']
  }
};

Are you willing to work on this yourself?

yes, but i do not good at english very well, i need help😄

Jiang-Xuan avatar Jun 18 '20 01:06 Jiang-Xuan

I think you're referring to https://webpack.js.org/concepts/entry-points/#single-entry-shorthand-syntax. There's another page https://webpack.js.org/configuration/entry-context/#entry which covers more cases.

chenxsan avatar Jun 18 '20 12:06 chenxsan

Missing usage: image

Jiang-Xuan avatar Jun 19 '20 01:06 Jiang-Xuan

@chenxsan if you think i am wrong, feel free to close this issue 😉

Jiang-Xuan avatar Jun 19 '20 14:06 Jiang-Xuan

I am willing to work on this issue...is it open?

mitchell-frost avatar Jul 30 '20 06:07 mitchell-frost

@mitchell-frost Thanks, It is open 🍻
@chenxsan

Jiang-Xuan avatar Jul 30 '20 07:07 Jiang-Xuan