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

unify ember fastboot --watch + ember server #274

Closed
stefanpenner opened this issue Oct 7, 2016 · 2 comments · Fixed by #356
Closed

unify ember fastboot --watch + ember server #274

stefanpenner opened this issue Oct 7, 2016 · 2 comments · Fixed by #356

Comments

@stefanpenner
Copy link
Contributor

ember fastboot --watch

and

ember server

are essentially the same feature. Or at the very least ember server should also provide fastboot, so that regular development is fastboot aware (catch issues early etc).


I believe the crux of the problem, is that there is no public API to make fastboot and ember serve work together easily.

specifically: https://github.com/ember-cli/ember-cli/blob/master/lib/tasks/server/middleware/serve-files/index.js#L22 is a black box, but we most likely want to make "serving" the actually assets intercept-able.

Now in theory, one could remove the entire middleware, but this would largely require reimplementing the entire middleware only to add a small hook, which ultimately will just cause future grief as the two diverge, or as a third feature wants to also provide additional behavior here.

broccoli-middleware is a module we control: https://github.com/ember-cli/broccoli-middleware and can make easily make changes to. Most likely here (but more then likely this whole file will need some refactor to make this work.

The design I believe would work is: "I'm about to serve index.html` tell me what I'm actually supposed to do.

The public handler that would be provided via configurable most likely would look very similar to an express middleware (but promise aware);

// default/existing handler
function indexHandler(path, response, request, next) {
  return fs.readFileSync(...);
}
// the fastboot variant
function fastbootHandler(path, response, request, next) {
  return app.visit(path).then(result => result.html()).then(html => request.send(html));
}

Goals:

  • continue to benefit from existing broccoli middleware features (serving the error page when the build breaks for example)
  • pluggable "serving" of the index.html file
  • promise aware (so we propagate errors nicely)
  • allow for streaming responses, so that known parts (html head etc can be flushed early, and more advanced plugins can stream in data after flushing the minimal viable html. (likely "just work" if we support the above API.

Stuff to do

  • actually design pluggable interface for broccoli-middleware
  • implement / refactor broccoli-middleware to support the above design
  • make sure ember-cli provides a way to

Pre-reqs

  • explore more scenarios that may need this, if found consider them.
  • ??

Acceptance

  • unify serve + fastboot
  • minify divergence
@kratiahuja
Copy link
Contributor

Update: Now that the RFC linked here is implemented and merged in. I'll look at fixing this next.

@kratiahuja
Copy link
Contributor

WIP PR to fix this issue: #356

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