Webpack-cli: [Discussion] Recommend using async/await for prompting

Created on 20 Apr 2019  Β·  20Comments  Β·  Source: webpack/webpack-cli

Do you want to request a feature or report a bug?

Discussion

What is the current behavior?
Currently, we are writing promise chains for prompting, which reduces readability as we nest deeper and deeper.

If the current behavior is a bug, please provide the steps to reproduce.

N/A

What is the expected behavior?
Using async/await for prompting. Example:
https://github.com/rishabh3112/webpack-scaffold-starter/blob/78889a176932ab2c5dadfb2c1d3946cc813bfda5/index.js#L57-L63

If this is a feature request, what is motivation or use case for changing the behavior?
N/A
Please paste the results of webpack-cli info here, and mention other relevant information such as programming language.
N/A


If it looks fine to all, I would PR for migrating generators in webpack-cli, webpack-scaffold-pwa and webpack-scaffold-vue

List of generators to be migrated

  • [x] add-generator : @rishabh3112 #843
  • [x] addon-generator : @anshumanv #849
  • [x] init-generator : @misterdev #817
  • [x] loader-generator : -
  • [x] plugin-generator : -
  • [x ] ~remove-generator : @dhruvdutt (?)~ Not needed now ;)
  • [x] update-generator : -
  • [ ] webpack-scaffold-pwa : -
  • [ ] webpack-scaffold-vue : @misterdev (?)
Discussion

Most helpful comment

Sure, let me make a checklist of all the generators, when on laptop, and lets collaborate πŸ€“

All 20 comments

πŸ‘ for this, would lead to much cleaner code.

We still support node 6, we can't remove them.
Although we can consider it to the next major version (which already uses them), look at the next branch.

If it looks fine to all, I would PR for migrating generators in webpack-cli, webpack-scaffold-pwa and webpack-scaffold-vue

The title says async/await but here talk about generators. Which one do you refer to?

I meant to migrate prompting() of yeoman generators to async/await.
For example add-generator, etc we have in CLI

Also, as we are using TS, we don't need to worry as TSC will polyfill based on our target while compilation.

Sounds good so!

Picking addon generator if it's cool 🀚

If it's ok I can include this change into the refactor of the init generator I'm currently working on :)

Sure, let me make a checklist of all the generators, when on laptop, and lets collaborate πŸ€“

I'm working on the remove generator. 😁 πŸ˜…

Just a heads up to prevent extra work, add is done here - https://github.com/webpack/webpack-cli/pull/843 πŸ˜„

I think @anshumanv is talking about the add generator :)

Have updated the issue with who is on whatβœ”
Look and work accordingly

@rishabh3112 @ematipico @misterdev I would love to give it a try in-order to refactor packages/serve. Let me know if it is within the scope here.

Yes it is, feel free to send a PR πŸ™‚

This would be great and we can refactor to use that. Reason for not having it in the first place was to support legacy node version, but minimal supported now is v.8 and it was introduced in 7.6, so go ahead

Init generator is probably most important to use this first with, then add

Anything missing here @rishabh3112 ?

Yes, opened to flag existing scaffold developers to use async/await for thiers scaffolds too.

Even though this can be opened in individual repos but I think having things centralized in the first iteration would be better.

This is mostly on us, if we implement async await in our generators, that will fix the issue. Is that done? I think we've implemented that already

Yup

Was this page helpful?
0 / 5 - 0 ratings