angular / angular/angularfire

Angular 19 SSR cloud functions ESM build

未关闭
#3,645 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
7.8k
派生
2.2k
平均合并
22 小时 28 分钟
30 天内合并 PR
6

描述

- [ ] unable to serve/deploy ssr functions esm build artifacts with vanilla cloud functions
- [x] able to ng serve, ng build (build-angular:application), and node ./server.mjs
- [x] other functions unrelated to SSR are working (server backend) as intended

Heres my SSR setup:

universal.ts

```typescript
import { onRequest } from 'firebase-functions/v2/https';
import { render } from '../../render.js';
import express, { Request, Response, NextFunction } from 'express';
import * as server from '../../../dist/stamp-app/server/server.mjs';
export const ssrApp = express() as any;

ssrApp.use(express.static('dist/stamp-app/browser'));
ssrApp.get('*', async (req: Request, res: Response, next: NextFunction) => {
const ssr: any = await render(server, req, res, next);
res.send(ssr);
});

export const universal = onRequest(
{ maxInstances: 10, timeoutSeconds: 1200, cpu: 1, memory: '2GiB', region: ['us-central1'] },
ssrApp
);
```
render.js
```typescript
import { Request, Response, NextFunction } from "express";

export async function configServerApp(app: any, req: Request, res: Response, next: NextFunction) {
//configure app here & retrieve HTML
let template;
if (req.path === '/') {
// template = await fetch('@dist/stamp-app/browser/index.csr.html');
next();
}
template = `

HTML CONTENT FOR SSR APP
`;
return template;
}
export async function render(app: any, req: Request, res: Response, next: NextFunction) {
const ssrApp = await configServerApp(app, req, res, next);
return ssrApp;
}
```

am I missing something..? thanks for any help in advance

贡献指南

打开贡献指南

调研方向

从 universal.ts 和 render.js 开始,然后复现 ng build (build-angular:application)、node ./server.mjs 与 SSR 函数部署之间报告的差异。检查生成的 dist/stamp-app/server/server.mjs 和浏览器产物,并与原生 Cloud Functions 设置进行对照。使用 ESM 构建时,SSR 函数能够成功提供服务并完成部署,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, express, firebase, node.js, typescript
领域
backend, cloud
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
需要澄清
新手友好度
43/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。