简体   繁体   English

运行浏览器中的开发服务器(例如stackblitz / codesandbox)

[英]Running in-browser development server [like stackblitz/codesandbox]

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. StackblitzCodeSandbox是两个提供在线IDE来开发Web应用程序的平台。 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." Stackblitz在其公告中描述了他们使用“ Progressive Web App API来在浏览器中运行实时开发服务器”。

  2. To resolve node dependencies stackblitz uses their custom npm client turbo . 为了解决节点依赖性,stackblitz使用其自定义的npm客户端turbo On the github repo page, it is described as 在github repo页面上,它被描述为

Express.js routes used for hydrating client-side dependencies and type definitions on StackBlitz. Express.js路由用于补充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. 怀疑 stackblitz在服务工作者中运行了express.js服务器,但我似乎不明白如何。 I'm out of ideas here, any help would be appreciated. 我在这里没有想法,任何帮助将不胜感激。

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. 如果您只是专注于前端代码,那么我想做的就是利用所需的任何模块来评估vm中的代码。 React will allow you to convert the JS into html. React将允许您将JS转换为html。 You can update the HTML directly in the dom. 您可以直接在dom中更新HTML。

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! 如果您有兴趣贡献者,那么我将为您的项目提供帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM