quasar icon indicating copy to clipboard operation
quasar copied to clipboard

SSR Fastify support (experimental) #8945

Open mav-rik opened this issue 3 years ago • 1 comments

What kind of change does this PR introduce? (check at least one)

  • [ ] Bugfix
  • [X] Feature
  • [X] Documentation
  • [ ] Code style update
  • [ ] Refactor
  • [X] Build-related changes
  • [ ] Other, please describe:

Does this PR introduce a breaking change? (check one)

  • [ ] Yes
  • [X] No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • [X] It's submitted to the dev branch (or v[X] branch)
  • [X] When resolving a specific issue, it's referenced in the PR's title (e.g. fix: #xxx[,#xxx], where "xxx" is the issue number)
  • [ ] It's been tested on a Cordova (iOS, Android) app
  • [ ] It's been tested on a Electron app
  • [X] Any necessary documentation has been added or updated in the docs (for faster update click on "Suggest an edit on GitHub" at bottom of page) or explained in the PR's description.

If adding a new feature, the PR's description includes:

  • [X] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

The reason

Fastify is well-known for its optimized workload overhead which makes it faster than express. Many people use fastify. I find it frustrating lacking of fastify in quasar ssr. Me personally would like to use quasar ssr + fastify webserver. There is an issue #8945 related to this PR

The solution

I've added an option for quasar mode add ssr to choose fastify. When you choose it you'll get:

  1. fastify dependencies to your project
  2. src-ssr folder with compress and render "middlewares" compatible with fastify
  3. quasar dev -m ssr will spin up the fastify server and proxy webpack devServer to it
  4. quasar build -m ssr will create proper entry files to serve via fastify

This PR does not affect anything if for quasar mode add ssr you choose Express.

Cons

For quasar dev -m ssr it looks a bit messy to spin up fastify server along with webpack's express one. But I couldn't find another solution for dev. I added fastify option to quasar.conf.js under ssr object which is used to distinguish fastify and express build. It has to be set true manually which is not very convenient. I'd like to set it true automatically when you choose to use fastify server. But I don't think it's possible. As far as I could find no other mode never changes the quasar.conf.js file.

mav-rik avatar Oct 03 '21 14:10 mav-rik

@mav-rik Thank you for this effort. I would also like to use Fastify as the SSR backend as it is typically more performant than express.

FYI, It looks like there are some conflicts with this branch, maybe it just needs to be rebased.

You might also consider reworking this based on the new Quasar-Vite configuration which gets rid of Webpack. Then it should just be a matter of using the fastify-vite plugin to wire up Fastify.

Blfrg avatar Jul 04 '22 18:07 Blfrg

This is greatly outdated as it targets @quasar/app which is replaced by @quasar/app-webpack. The related issue has been addressed, so this PR won't be needed. Thanks for your efforts.

yusufkandemir avatar Jan 19 '24 17:01 yusufkandemir