Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise based webpack configs fail #1946

Closed
1 of 2 tasks
jspears opened this issue May 31, 2019 · 3 comments · Fixed by #1947
Closed
1 of 2 tasks

Promise based webpack configs fail #1946

jspears opened this issue May 31, 2019 · 3 comments · Fixed by #1947

Comments

@jspears
Copy link

jspears commented May 31, 2019

  • Operating System: OSX
  • Node Version:v8.10.0
  • NPM Version: 5.6.0
  • webpack Version:4.28.4
  • webpack-dev-server Version:3.5.0
  • This is a bug
  • This is a modification request

Code

When using a promise based configuration the error responds with

TypeError: Cannot read property 'bonjour' of undefined
    at createConfig (node_modules/webpack-dev-server/lib/utils/createConfig.js:13:12)
    at processOptions (node_modules/webpack-dev-server/lib/utils/processOptions.js:22:19)

// webpack.config.js
module.exports = new Promise(r=>setTimeout(r, 100, {}));

Expected Behavior

When using a promise to launch webpack-dev-server the

in

//processOptions.js 
function processOptions(config, argv, callback) {
  // processOptions {Promise}
  if (typeof config.then === 'function') {
///ERROR HERE -- argv is not passed ///
    config.then(processOptions).catch((err) => {
      // eslint-disable-next-line no-console
      console.error(err.stack || err);
      // eslint-disable-next-line no-process-exit
      process.exit();
    });

    return;
  }

Actual Behavior

Should be something like

function processOptions(config, argv, callback) {
  // processOptions {Promise}
  if (typeof config.then === 'function') {
///Fixed by passing argv.
    config.then( c =>processOptions(c, argv, callback)).catch((err) => {
      // eslint-disable-next-line no-console
      console.error(err.stack || err);
      // eslint-disable-next-line no-process-exit
      process.exit();
    });

    return;
  }

For Bugs; How can we reproduce the behavior?

A solution is above.

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

@hiroppy
Copy link
Member

hiroppy commented May 31, 2019

thanks, duplicated of #1945, so I'll close

@hiroppy hiroppy closed this as completed May 31, 2019
@hiroppy
Copy link
Member

hiroppy commented May 31, 2019

If you have the reproducible repo, please submit it.

@jspears
Copy link
Author

jspears commented May 31, 2019

If you have the reproducible repo, please submit it.

yeah but this one has a fix.

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 a pull request may close this issue.

2 participants