3

The Question:

How to run a live in-browser dev server?


Context

Stackblitz and CodeSandbox are two platforms that provide online IDE to develop web applications. I have a similar use case, and would need to run an in browser dev server, but there's not much that I was able to find, apart from these few observations.


Few Observations

  1. Stackblitz, in their announcement post describe that they use, "Progressive Web App API’s to run a live dev server in-browser."

  2. To resolve node dependencies stackblitz uses their custom npm client turbo . On the github repo page, it is described as

Express.js routes used for hydrating client-side dependencies and type definitions on StackBlitz.

  1. There is also some module bundler involved to support live development with hot-reloading.

I suspect stackblitz runs an express.js server in the service worker, but i can't seem to understand how. I'm out of ideas here, any help would be appreciated.

Community
  • 1
  • 1
Nishkal Kashyap
  • 960
  • 7
  • 17

1 Answers1

0

I'll be honest, I have no idea but I'd like to wildly speculate.

If you're going to just be focusing on front end code, then what I would think to do is to evaluate the code in your vm with the context of whatever modules are required. React will allow you to convert the JS into html. You can update the HTML directly in the dom.

I'm not sure how much help that is, but I will leave you with this

If you're interested in having a contributor, then I'm down to team up on your project!

Sean Kelly
  • 901
  • 7
  • 27
  • 1
    I'll be making the project open-source, I'll update here once I do so, you're most welcome for your contributions. As for your answer, it did not help. However I've almost found the way they do it, will shortly post the answer. Or better still, a node package to do so. – Nishkal Kashyap Nov 16 '18 at 19:16