GithubHelp home page GithubHelp logo

zhangyuang / ssr Goto Github PK

View Code? Open in Web Editor NEW
2.5K 34.0 282.0 24.87 MB

A most advanced ssr framework support React17/React18/Vue2/Vue3 on Earth that implemented serverless-side render specification.

Home Page: http://doc.ssr-fc.com/

License: MIT License

TypeScript 81.88% JavaScript 3.66% Less 7.52% Vue 6.94%
ssr serverless node midway-faas vite webpack vue react nestjs csr

ssr's Introduction

简体中文 | English

SSR


A most advanced ssr framework on Earth that implemented serverless-side render specification for faas and traditional web server.


ssr 框架是为前端框架在服务端渲染的场景下所打造的开箱即用的服务端渲染框架。了解什么是服务端渲染请查看文档

此框架脱胎于 egg-react-ssr 项目和 ssr v4版本(midway-faas + react ssr),在之前的基础上做了诸多演进,通过插件化的代码组织形式,支持任意服务端框架与任意前端框架的组合使用。开发者可以选择通过 Serverless 方式部署或是以传统 Node.js 的应用形式部署,并且我们专注于提升 Serverless 场景下服务端渲染应用的开发体验,打造了一站式的开发,发布应用服务的功能。最大程度提升开发者的开发体验,将应用的开发,部署成本降到最低。

在最新的版本中,同时支持 React17/18Vue2/Vue3 作为服务端渲染框架且开发工具侧我们同样支持了最流行的 Vite 来提升应用的启动速度和 HMR 速度,且提供一键以 Serverless 的形式发布上云的功能。我们可以非常有自信说它是地球上最先进的 ssr 框架。如果你希望获得开箱即用的体验且能够一键部署上云,请选择 ssr 框架。

阅读我们的 官方文档 获得更加详细的了解。事实上文档本身便是用 ssr 框架开发并通过 Serverless 部署到阿里云服务

什么情况下你应该选择 ssr 框架

  • 需要在 Node.js 与前端框架结合的场景使用,与其他纯前端的框架不同 ssr 框架是专为服务端渲染场景或者 Node.js 与前端结合的场景打造的框架
  • 需要一个开箱即用的服务端渲染能力,不需要手动去组合不同的前端框架与服务端框架之间的联系
  • 需要框架层面的渲染降级能力,在服务端渲染出错时自动降级到客户端渲染
  • 需要一个配置简单逻辑清晰的框架, ssr 框架的渲染逻辑和应用构建逻辑是同类型框架中最清晰的
  • 可能会改动技术栈,如从 Vue2 升级为 Vue3,从 Vue3 降级为 Vue2React/Vue 互相切换
  • 需要在服务端渲染场景下开箱即用使用 antd vant 等流行 ui
  • 需要能够同时支持 Webpack, Vite 两种开发工具,以便同时得到快速的启动速度 HMR 速度以及稳定的生产环境代码
  • 需要在 Vue3 SSR 使用 pinia 作为数据管理方案
  • 只是单纯的需要一个更快更好用的 cravue-cli, ssr 框架在纯 csr 场景的支持也十分优秀

哪些应用在使用

正在使用这个项目的公司(应用), 如果您正在使用但名单中没有列出来的话请提 issue,欢迎推广分享,我们将随时提供技术支持


优酷视频

微信公众平台

腾讯体育

QQ会员

腾讯视频
牛牛搭
牛牛搭

国盛证券
三易科技
三易科技

腾讯微卡
腾讯手游助手
腾讯手游助手
国家现代农业科技创新中心
国家现代农业科技创新中心

部署于阿里云示例应用

部署于腾讯云示例应用

100教育
Dream2qBlog
个人博客
Dream2qBlog
得物
微脉
微脉
行动教育
行动教育
Happy
HappyPC
Happy
HappyMobile

阿里影业娱乐宝
vmate 积分商城
Vmate短视频
火炽星原CRM
火炽星原CRM

拍信创意
极速二维码
极速二维码
cvte
希沃帮助中心
经传多赢股票网
经传多赢股票网
中商全球图书采选平台
中商全球图书采选平台

Features

  • 🌱 极易定制:前端支持 React17/React18/Vue2/Vue3 等现代Web框架;
  • 🚀 开箱即用:内置 10+ 脚手架配套扩展,如 Piniaantdvant、TypeScript、Hooks等;
  • 🧲 插件驱动:基于插件架构,用户更加专注于业务逻辑;
  • 💯 Serverless优先:一键发布到各种Serverless平台,也支持传统Web Server,比如Egg、Midway、Nest等。
  • 🛡 高可用场景,可无缝从SSR降级到CSR,最佳容灾方案。
  • 😄 功能丰富,构建工具同时支持 Webpack/Vite,支持四种渲染模式 SSR|CSR|SSG|Html
  • ✨ 支持 bun 作为 js runtime

已实现的功能

🚀 表示已经实现的功能

里程碑 状态
支持任意服务端框架与任意前端框架的组合使用。(Serverless/Midway/NestJS) + (React17/React18/Vue2/Vue3) 🚀
最丝滑的 vite 支持 🚀
最小而美的实现服务端渲染功能 🚀
支持预渲染能力 🚀
针对Serverless 场景对代码包的大小的严格限制,将生产环境的代码包大小做到极致 🚀
同时支持约定式前端路由和声明式前端路由 🚀
摒弃传统模版引擎,所有页面元素统一使用前端组件作为 DSL 🚀
同时支持四种渲染模式,提供服务端渲染一键降级为客户端渲染的能力 🚀
统一不同框架服务端客户端的数据获取方式,做到高度复用 🚀
类型友好,全面拥抱 TS 🚀
支持无缝接入 antd vant 无需修改任何配置 🚀
支持使用 less 作为 css 预处理器 🚀
微前端场景下无缝使用 🚀
支持使用 context 或 valtio 实现极简的数据管理方案,摒弃传统的 redux/dva 等数据管理方案 🚀
Vue3 场景提供 Pinia 以及 Provide/Inject 代替 Vuex 进行跨组件通信 🚀
支持在阿里云 云平台创建使用 🚀
ssr deploy 一键部署到阿里云平台 🚀
ssr deploy --tencent 无需修改任何配置一键部署到腾讯云平台 🚀

方案对比

为什么要选择 ssr 框架以及与同类型框架的方案对比请查看文档

快速开始

我们提供了 create-ssr-app 脚手架来让用户可以迅速的创建不同类型的应用。

目前官方提供了以下类型的模版给开发者直接使用。用户可根据自己的实际技术栈选择不同的模版进行开发。

虽然技术栈不同但开发**是一致的,在任何技术栈的组合中我们的开发命令, 构建命令以及渲染原理都是完全一致的

注意: 在 Midway.js Nest.js 场景下我们都已实现了一键部署到 Serverless 平台的能力。但底层实现略有差异。更加详细的介绍可以阅读 Serverless 章节。如需要大量使用 Serverless 平台提供的能力,我们建议创建 Midway.js 类型的应用。强烈建议阅读我们的 官方文档 来获得更加详细的了解

开发者可根据实际技术栈需要创建不同类型的应用快速开始

创建项目

通过 npm init 命令我们可以创建上述的任意模版

$ npm init ssr-app my-ssr-project
$ cd my-ssr-project
$ yarn # 建议使用 yarn, 也可以 npm install
$ yarn start
$ open http://localhost:3000 # 访问应用
$ yarn build # 资源构建,等价于 npx ssr build
$ yarn start:vite # 以 vite 模式启动,等价于 npx ssr start --vite

线上案例

通过访问以下链接来预览该框架通过 Serverless 一键部署到阿里云/腾讯云服务的应用详情。 通过使用 queryParams csr=true 来让 SSR 服务端渲染模式一键降级为 CSR 客户端渲染模式,也可以通过 config.js 来进行配置。

生态系统

Project Status Description
ssr ssr-status cli for ssr framework
ssr-core ssr-core-status core render for all framwork
ssr-plugin-midway ssr-plugin-midway-status provide start and build fetature by [email protected]
ssr-plugin-nestjs ssr-plugin-nestjs-status provide start and build feature by NestJS
ssr-plugin-react ssr-plugin-react-status develop react application only be used in development
ssr-plugin-vue ssr-plugin-vue-status develop vue2 application only be used in development
ssr-plugin-vue3 ssr-plugin-vue3-status develop vue3 application only be used in development
ssr-common-utils ssr-common-utils-status common utils in Node.js environment and browser
ssr-hoc-react ssr-hoc-react-status provide hoc component for react
ssr-hoc-vue3 ssr-hoc-vue3-status provide hoc component for vue3
ssr-types ssr-types-status provide common types
ssr-webpack ssr-webpack-status start local server and build production bundle by webpack

CONTRIBUTING

如果你想为本应用贡献代码,请阅读贡献文档,我们为你准备了丰富的脚本用于 bootstrap

License

MIT

答疑群

虽然我们已经尽力检查了一遍应用,但仍有可能有疏漏的地方,如果你在使用过程中发现任何问题或者建议,欢迎提issue或者PR

注: 由于微信交流群人数限制,进群请添加私人二维码并备注进入 ssr 交流群,由于是私人微信,拉群后将会自行删除好友,敬请谅解。我们更加鼓励通过 issue 和 discussion 来交流问题

项目捐赠

如果本项目能够对你有所帮助,希望得到来自于你的捐赠 ☕️ 为开源社区做一份贡献

代码行数

$ cloc packages --include-ext=ts
     993 text files.
     679 unique files.
     829 files ignored.

github.com/AlDanial/cloc v 1.90  T=0.62 s (264.7 files/s, 9026.5 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
TypeScript                     164            471            195           4927
-------------------------------------------------------------------------------
SUM:                           164            471            195           4927
-------------------------------------------------------------------------------

前端开发手册

如何打造舒适高效的前端开发环境

项目 Star 数增长趋势

Stargazers over time

ssr's People

Contributors

basicbuttons avatar baxtergu avatar ben-ben-b avatar benmccann avatar boguan avatar cokemine avatar dclangx avatar dellyoung avatar dependabot[bot] avatar edsion11 avatar hlskysong avatar i5ting avatar imsunhao avatar jerryyux avatar jiangmaniu avatar kagawagao avatar kuigoo avatar leesson avatar loyep avatar lyule avatar mervynfang avatar phecda avatar ranieryu avatar taoliujun avatar unclechong avatar winstonya avatar yreenchan avatar yuesong-feng avatar zhangyuang avatar zwjtheone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssr's Issues

接入微软fluentUI组件库问题

提问前请确认以下几点信息,否则你的问题将不会被解答

  • 参考 https://zhuanlan.zhihu.com/p/25795393 学会正确的提问方式
  • 确定已经阅读过文档 http://doc.ssr-fc.com/ 并且文档中搜索不到相关答案
  • 对应服务端框架的使用问题请去它们的官方文档找答案。例如 Midway, Nest.js
  • 如果你确认当前是一个 bug 请给最简复现仓库。只有一张图或者信息不足的问题将会被直接关闭
  • 原则上这里只解答与本框架有关的问题。关于其他问题例如 Node.js 怎么连 Mysql 怎么获取 cookie 这种基础问题你应该去 google找答案而不是在这里。

详细描述你的问题

希望在框架里引入 https://developer.microsoft.com/ja-jp/fluentui#/, 但是在引用后,会有错误,具体来讲,我在app.ts文件里
image
设置fluentUI的ssr flag,然后成功渲染,但是当我f5刷新时,报
image

期望的结果

能够成功在ssr中渲染响应组件

当前使用的版本

image

你本人对问题可能的原因判断(如果你能大概判断的话)

image

feat:是否支持 SSG

SSG 就是静态渲染,也就是预渲染。构建时生成页面 html 源码。优势就是 ssr 带来的优势只是不需要 Node.js 环境。缺点是只能渲染简单的静态界面
比较常用的场景是在纯静态展示页面例如官网博客等场景。

个人对是否支持 SSG 存观望态度。我认为这是一个伪需求

1、ssg 场景非常少
2、ssg 功能上完全可以被 ssr 代替
3、ssg 的构建时间略长
4、serverless 场景下拥有一个 Node.js 环境是非常容易的事情。不需要像以前一样手动购买服务器搭建环境。
5、ssg 会让数据 fetch 规范变得稍微复杂一点。ssg 场景下的 fetch 与 ssr 场景下的 fetch 不一定能共用一个方法。
6、如果开发者只是需要一个 html 文件用来做降级的话。那应该直接使用 http://doc.ssr-fc.com/docs/features$csr#%E7%8B%AC%E7%AB%8B%20html%20%E6%96%87%E4%BB%B6%E9%83%A8%E7%BD%B2

新增本地proxy能力

本地接口代理服务,两种解决方案
1、直接用webpack-dev-server的proxy。但是需要在faas本地开发的koa服务中用koa-proxy将对应的path映射到webpack-dev-server的服务
2、直接用koa-proxy,但配置相比于webpack-dev-server稍显复杂

ERR_REQUIRE_ESM

报错信息 Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/wanglei/Documents/Projects/ssr-test/node_modules/@[email protected]@@babel/runtime/helpers/esm/arrayWithHoles.js
require() of ES modules is not supported.
require() of /Users/wanglei/Documents/Projects/ssr-test/node_modules/
@[email protected]@@babel/runtime/helpers/esm/arrayWithHoles.js from /Users/wanglei/Documents/Projects/ssr-test/build/index/server/Page.server.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename arrayWithHoles.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/wanglei/Documents/Projects/ssr-test/node_modules/_@[email protected]@@babel/runtime/helpers/esm/package.json.

复现方法 https://github.com/ykfe/ssr#%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE 使用 npm 模板生成的项目就会出现问题

OS: macOS 10.14/15
node: v12.19.0
npm: 6.14.8

大概是在 @babel/runtime 这个库升级到 7.12.1 的时候出现的,看报错是说 Page.server.js 内用 require 引入了 esm 的模块

如何实现公共代码分割?

项目使用ant-design-vue按需加载,打包出来发现使用了ant-design-vue的页面体积都比较大,应该是没有把公共代码抽离出来

                       asset-manifest.json  937 bytes          [emitted]
         static/css/Page.563401ad.chunk.css  490 bytes       0  [emitted] [immutable]         Page
        static/css/login.aa6e9184.chunk.css    196 KiB       5  [emitted] [immutable]         login
    static/css/not-found.7ee405a1.chunk.css   83.2 KiB       7  [emitted] [immutable]         not-found
           static/js/Page.19ba46f3.chunk.js   7.55 KiB       0  [emitted] [immutable]         Page
static/js/detail-id-fetch.56f379b1.chunk.js  433 bytes       2  [emitted] [immutable]         detail-id-fetch
      static/js/detail-id.a7b2e3a9.chunk.js  324 bytes       1  [emitted] [immutable]         detail-id
 static/js/index-id-fetch.b32a858e.chunk.js  419 bytes       4  [emitted] [immutable]         index-id-fetch
          static/js/index.45387c44.chunk.js  417 bytes       3  [emitted] [immutable]         index
    static/js/login-fetch.7dbde7b6.chunk.js  448 bytes       6  [emitted] [immutable]         login-fetch
          static/js/login.917ccee6.chunk.js    619 KiB       5  [emitted] [immutable]  [big]  login
static/js/not-found-fetch.70744618.chunk.js  430 bytes       8  [emitted] [immutable]         not-found-fetch
      static/js/not-found.bdb5f353.chunk.js    505 KiB       7  [emitted] [immutable]  [big]  not-found
         static/js/runtime~Page.abd4df38.js   3.51 KiB       9  [emitted] [immutable]         runtime~Page
         static/js/vendor.0b6eb950.chunk.js    209 KiB      10  [emitted] [immutable]         vendor

如上,login页面和not-found页面都使用按需加载ant-design-vue
建议给ssr-plugin-vue3的chainClientConfig添加以下默认配置
···
chain.optimization
.splitChunks({
chunks: 'async',
minSize: 20000,
minChunks: 1,
maxAsyncRequests: 30,
maxInitialRequests: 30,
enforceSizeThreshold: 50000,
cacheGroups: {
defaultVendors: {
test: /[\/]node_modules[\/]/,
priority: -10,
reuseExistingChunk: true
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true
}
}
})
.end()
···

可否通过配置,选择性的在服务端渲染时,使用react自带的 useContext

问题:
1.目前midway-react-ssr 的服务端渲染强绑定了 react自带的 useContext. 当不需要时它依然会执行,且只有通过useContext才使用服务端渲染所需数据.
2. 而payload中注入的 window.INITIAL_DATA, 只有在客户端可以访问,无法满是服务端渲染的需求
__html: window.USE_SSR=true; window.INITIAL_DATA =${serialize(state)};`
需求:
1.通过配置控制服务端渲染时是否使用react自带的 useContext。 不使用时框架能提供一个可访问服务端渲染数据的接口

两个页面的fetch.ts返回数据混合

plugin-vue3/src/entry/client-entry.ts
image
fetch.ts 返回的数据合并进 asyncData 使用的是reactive 不必添加 .value包装 也不会丢失响应性

在 vue3当中 ref() 响应式 是带有 .value 包装的 reactive() 是通过proxy 实现的 无需 .value包装
带有 .value 还会在后续取值的操作上 重复写出 带有 .value 的代码

文档优化意见收集

你期待的好用的文档是怎么样的?
文档是否缺失了什么?
希望哪些部分更加详细?

关于文档的任何意见,欢迎直接反馈到这里,我们会持续优化。

feat: vue场景支持可选参数

vue 场景原生支持 /:id? 这种形式的路由。访问 /, /:id 都能够匹配上。

react 场景原生不支持,暂不实现

打算 render$id? -> /:id? ,render$foo?$bar -> /:foo?/:bar

用户常见问题收集

收集用户的常见问题和回答,沉淀到文档的常见问题章节中。

抛个砖

如何阿里云使用?
如何集成nest?
如何结合cdn来发布?

Roadmap

接下来的计划如下

解耦代码

1、解耦框架。使其能够同时运行在 serverless 场景 和 传统的 Node.js 应用场景
2、底层 webpack 解耦。后续考虑接入 vite
3、前端框架解耦,接入vue

API 优化

API 设计原则:

简单易用:用尽可能少的 api 和参数完成完备的功能
语义清晰:API的命名约定具有一致性和精确性,便于记忆
欢迎大家在下面留言 ssr API 不合理的地方

例如

所有配置中 config 的 clientPlugin 使用和 serverPlugin 要保持一致

Only use vite (+ vite-plugin-ssr)?

Hi, neat project. I like the framework-agnosticity of it.

Have you thought of going all-in with Vite instead of also supporting Webpack? This would likely simplify the stack.

I'm the author of https://github.com/brillout/vite-plugin-ssr and I designed it to be a do-one-thing-do-it-well composable tool. Maybe using vite-plugin-ssr would make your life easier?

Exicting to see the Vite ecosystem growing.

package

  • core: webpack-config clientRender serverRender
  • utils: getComponent wrapperHOC
  • cli: ssr start, ssr build, ssr deploy

多级路由匹配问题

路由如下
/webview/v1/activity/dubber
并在 page 建立与之对应的文件夹
image

webview 文件夹中不存在 /webview/render.tsx 时页面无法正常渲染,报错如下

ERROR in ./web/pages/webview/render.tsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: ENOENT: no such file or directory, open '/Users/luowei/Workspace/alpha/web/pages/webview/render.tsx'
 @ ./build/ssr-temporary-routes.js 60:11-62:33
 @ ./node_modules/ssr-plugin-vue3/cjs/entry/client-entry.js
 @ multi ./node_modules/ssr-plugin-vue3/cjs/entry/client-entry.js

webview 文件夹下面存在 render.tsx 时页面能够正常渲染,渲染内容为 /webview/v1/activity/dubber/render.tsx 中的内容

新项目vite 404

您好,新建ssr midwayjs+vue3项目后使用vite访问任意页面404,操作步骤与debug日志如下:

$ npm init ssr-app wenku -- --template=midway-vue3-ssr
$ cd wenku && yarn && yarn add -D vite @vitejs/plugin-vue
$ yarn vite -d
yarn run v1.22.10
$ D:\test\wenku\node_modules\.bin\vite -d
  vite:config no config file found. +0ms
[dotenv][DEBUG] did not match key and value when parsing line 1:
[dotenv][DEBUG] did not match key and value when parsing line 6:
  vite:config using resolved config: {
  vite:config   root: 'D:/test/wenku',
  vite:config   base: '/',
  vite:config   mode: 'development',
  vite:config   configFile: undefined,
  vite:config   logLevel: undefined,
  vite:config   clearScreen: undefined,
  vite:config   server: {},
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     server: {}
  vite:config   },
  vite:config   resolve: { dedupe: undefined, alias: [ [Object] ] },
  vite:config   publicDir: 'D:\\test\\wenku\\public',
  vite:config   command: 'serve',
  vite:config   isProduction: false,
  vite:config   optimizeCacheDir: 'D:\\test\\wenku\\node_modules\\.vite',
  vite:config   plugins: [
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite:dynamic-import-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge18', 'firefox60', 'chrome61', 'safari11' ],
  vite:config     polyfillDynamicImport: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     minify: 'terser',
  vite:config     terserOptions: {},
  vite:config     cleanCssOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     brotliSize: true,
  vite:config     chunkSizeWarningLimit: 500
  vite:config   },
  vite:config   env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen]
  vite:config   },
  vite:config   createResolver: [Function: createResolver]
  vite:config } +8ms
  vite:deps Hash is consistent. Skipping. Use --force to override. +0ms

  vite v2.1.5 dev server running at:

  > Network:  http://172.18.0.1:3000/
  > Network:  http://172.20.192.1:3000/
  > Network:  http://192.168.10.157:3000/
  > Network:  http://172.16.3.168:3000/
  > Network:  http://192.168.56.1:3000/
  > Network:  http://192.168.24.1:3000/
  > Network:  http://192.168.112.1:3000/
  > Network:  http://192.168.10.200:3000/
  > Local:    http://localhost:3000/

  ready in 234ms.

  vite:hmr [file change] .idea/workspace.xml +0ms
  vite:hmr [no modules matched] .idea/workspace.xml +1ms
  vite:spa-fallback Rewriting GET /?csr=1 to /index.html +0ms
  vite:time 8ms   /index.html +0ms

cr

issues

  • plugin-faas和plugin-midway分的不好
  • plugin代码在哪里?别人如何扩展
  • "vue": "^2.0.0",??
  • vite部分没有看到
  • create-ssr-app集成没有
  • example和其他地方不要过度强调midway,这个版本主导Serverless
  • example里既有midway又有egg,依赖需要处理一下。
  • 测试基本没有。只有jest配置。
  • fePlugin命名不好

优点

const { midwayPlugin } = require('ssr-plugin-midway')
const { vuePlugin } = require('ssr-plugin-vue')

module.exports = {
  serverPlugin: midwayPlugin(),
  fePlugin: vuePlugin()
}

用起来确实简单很多。接下来plugin围绕扩展,还有很多工作要做。

安装 typeorm 无法使用

  1. 安装依赖
yarn add @nestjs/typeorm typeorm mysql2
  1. 引入配置 src/app.module.ts
import { Module } from '@nestjs/common'
import { DetailModule } from './modules/detail-page/detail.module'
import { indexModule } from './modules/index-page/index.module'
import { TypeOrmModule } from '@nestjs/typeorm'

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: 'localhost',
      port: 3306,
      username: 'root',
      password: 'root',
      database: 'test',
      entities: [],
      synchronize: true
    }),
    DetailModule,
    indexModule
  ]
})
export class AppModule {}

此时无法运行 程序报错 报错信息如下

[Nest] 17028   - 08/03/2021, 2:57:46 PM   [NestFactory] Starting Nest application...

[Nest] 17028   - 08/03/2021, 2:57:46 PM   [InstanceLoader] AppModule dependencies initialized +26ms

[Nest] 17028   - 08/03/2021, 2:57:46 PM   [InstanceLoader] TypeOrmModule dependencies initialized +0ms

error: [Nest] 17028   - 08/03/2021, 2:57:46 PM   [ExceptionHandler] rxjs_1.lastValueFrom is not a function +1ms

error: TypeError: rxjs_1.lastValueFrom is not a function
    at Function.<anonymous> (/Users/macos/Desktop/ssr/node_modules/@nestjs/typeorm/dist/typeorm-core.module.js:146:33)
    at Generator.next (<anonymous>)
    at /Users/macos/Desktop/ssr/node_modules/@nestjs/typeorm/dist/typeorm-core.module.js:20:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/macos/Desktop/ssr/node_modules/@nestjs/typeorm/dist/typeorm-core.module.js:16:12)
    at Function.createConnectionFactory (/Users/macos/Desktop/ssr/node_modules/@nestjs/typeorm/dist/typeorm-core.module.js:143:16)
    at Function.<anonymous> (/Users/macos/Desktop/ssr/node_modules/@nestjs/typeorm/dist/typeorm-core.module.js:46:96)
    at Generator.next (<anonymous>)
    at /Users/macos/Desktop/ssr/node_modules/@nestjs/typeorm/dist/typeorm-core.module.js:20:71
    at new Promise (<anonymous>)

是不允许这样使用还是我的配置有问题。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.