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

Compiler Callback and Promises #144

Closed
shellscape opened this issue Oct 27, 2016 · 2 comments
Closed

Compiler Callback and Promises #144

shellscape opened this issue Oct 27, 2016 · 2 comments

Comments

@shellscape
Copy link
Contributor

For any system that relies on middleware to finish its processes before continuing onto the next tick, webpack-dev-middleware presents headaches.

At https://github.com/webpack/webpack-dev-middleware/blob/master/middleware.js#L156 the callback to compiler.run is of no use other than to report an error. If this middleware were to implement Promises, or at the least chained error-first callbacks all the way to the exported middleware function (allowing folks to wrap in promises or use thunks), other components could rely on it finishing before proceeding. And that would be a major improvement.

As of now the middleware returns immediately, while the compiler may not have finished. This causes unexpected issues down the pipe. Such an issue is documented here: shellscape/koa-webpack#2

@SpaceK33z
Copy link
Member

I don't think implementing Promises is a good idea for now, since webpack still uses callback style methods. I'd rather wait for webpack to implement Promises.

However, I'm open to providing more hooks. Note also that after #140 it should be easier to implement middleware for other servers.

@jescalan
Copy link

@SpaceK33z would you be open to a PR adding a catch-all compiler callback hook? Right now, there's a hook for errors that works, but not really any hooks to indicate success. Honestly, it would be easier to just have one generic callback with an error parameter as the first argument. I know this would be a breaking change though so might be tough 😕

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

No branches or pull requests

3 participants