Angular 19 SSR cloud functions ESM build
- Ngôn ngữ chính
- TypeScript
- Star
- 7.8k
- Fork
- 2.2k
- Merge trung bình
- 22 giờ 28 phút
- Pull request đã merge (30 ngày)
- 6
Mô tả
- [ ] 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 = `
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
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với universal.ts và render.js, sau đó tái hiện khác biệt đã được báo cáo giữa ng build (build-angular:application), node ./server.mjs và việc triển khai các hàm SSR. Kiểm tra dist/stamp-app/server/server.mjs được tạo ra cùng các artifact của trình duyệt, đối chiếu với thiết lập vanilla của Cloud Functions. Hoàn tất khi hàm SSR phục vụ và triển khai thành công với bản build ESM.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, express, firebase, node.js, typescript
- Lĩnh vực
- backend, cloud
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 43/100