Skip to content

docs(examples): add yarn add webpack-cli step - #7174

Merged
sokra merged 1 commit into
webpack:masterfrom
JLHwung:revise-examples-build-readme
May 25, 2018
Merged

sokra merged 1 commit into
webpack:masterfrom
JLHwung:revise-examples-build-readme

Conversation

@JLHwung

@JLHwung JLHwung commented May 2, 2018

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?
docs change

Did you add tests for your changes?
No

If relevant, link to documentation update:
No

Summary

Running node cd examples/commonjs && node ./build.js without webpack-cli installed will get hang.

The culprit is that webpack expects a stdin user input of whether to install webpack-cli or not. However, as examples/build-common uses child_process.exec to execute webpack, the user will not be prompted for any questions since the stdin is not piped and the stdout will be pass to parent process only after the child process exits. We can keep build-common simple by instructing devs to install webpack-cli before they build examples.

Also rewrite the install step using yarn since we use yarn in webpack.

Does this PR introduce a breaking change?
No

Other information
No

Alternative Solution
Add webpack-cli to devDependencies.

Running node_modules/bin/webpack without webpack-cli installed will get hang.

The culprit is that webpack expects a stdin of whether to install webpack-cli or not. However, as examples/build-common use `child_process.exec` to execute `webpack`, the user will not be prompted for any questions since the stdin is not piped and the stdout will be pass to parent process only after the child process exits. We can keep build-common simple by instructing devs to install webpack-cli before they build examples.

Also rewrite the install step using yarn since we use yarn in webpack.
@webpack-bot

Copy link
Copy Markdown
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@webpack-bot

webpack-bot commented May 15, 2018

Copy link
Copy Markdown
Contributor

For maintainers only:

  • This need to be documented (issue in webpack/webpack.js.org will be filed when merged)

Comment thread examples/README.md
3. Run `node build.js` in the specific example directory. (Ex: `cd examples/commonjs && node build.js`)
1. Run `yarn` in the root of the project.
2. Run `yarn link webpack` in the root of the project.
3. Run `yarn add --dev webpack-cli` in the root of the project.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about if i use npm? Looks like better have two variants

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, yarn is used to align with https://github.com/webpack/webpack/blob/master/_SETUP.md#setup. Personally I am good to either one as long as documented in contribution guide.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must be yarn. npm don't read the yarn.lock file so it yields different results.

Comment thread examples/README.md
3. Run `node build.js` in the specific example directory. (Ex: `cd examples/commonjs && node build.js`)
1. Run `yarn` in the root of the project.
2. Run `yarn link webpack` in the root of the project.
3. Run `yarn add --dev webpack-cli` in the root of the project.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must be yarn. npm don't read the yarn.lock file so it yields different results.

@sokra
sokra merged commit 5feb7e6 into webpack:master May 25, 2018
@sokra

sokra commented May 25, 2018

Copy link
Copy Markdown
Member

Thanks

@JLHwung
JLHwung deleted the revise-examples-build-readme branch May 26, 2018 02:18
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

Successfully merging this pull request may close these issues.

4 participants