Skip to content
New issue

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

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

Already on GitHub? # to your account

webpack-dev-server not accepting promise #417

Closed
crohde7707 opened this issue Feb 29, 2016 · 0 comments
Closed

webpack-dev-server not accepting promise #417

crohde7707 opened this issue Feb 29, 2016 · 0 comments

Comments

@crohde7707
Copy link
Contributor

Noticed that when using webpack, you are able to return a Promise instead of an object as a valid parameter. I would assume that webpack-dev-server would be the same case, but it looks like it was an oversight. The code in question is as follows

webpack-dev-server/bin/webpack-dev-server.js

var wpOpt = require("webpack/bin/convert-argv")(optimist, argv, { outputFilename: "/bundle.js" });
var firstWpOpt = Array.isArray(wpOpt) ? wpOpt[0] : wpOpt;
var options = wpOpt.devServer || firstWpOpt.devServer || {};
...

webpack/bin/webpack.js

var options = require("./convert-argv")(yargs, argv);
...
function processOptions(options) {
    // process Promise
    if(typeof options.then === "function") {
        options.then(processOptions).catch(function(err) {
            console.error(err.stack || err);
            process.exit(); // eslint-disable-line
        });
        return;
    }

    var firstOptions = Array.isArray(options) ? options[0] : options;

    var outputOptions = Object.create(options.stats || firstOptions.stats || {});
    if(typeof outputOptions.context === "undefined")
        outputOptions.context = firstOptions.context;
...
}
processOptions(options);

Tried looking through the issues log for something like this, but couldn't find it, and it doesn't look like its fixed in the latest version

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants