firebase / firebase/firebase-admin-node
[FR] Bundle size
- 主要语言
- TypeScript
- 星标
- 1.7k
- 派生
- 419
- 平均合并
- 3 天 10 小时
- 30 天内合并 PR
- 16
描述
**Is your feature request related to a problem? Please describe.**
When using `firebase-admin` on AWS lambda it adds a big blog to the bundle size. We are using `esbuild` to bundle our sources written in TS, and bundling the admin sdk adds an extra of 5.7MB, minified 2.8MB. This is far from optimal, because the bundle should be as small as possible for better cold-start performance. The code looks like this:
```js
import * as admin from "firebase-admin";
const app = admin.initializeApp();
console.log("app :>> ", app);
const firestore = app.firestore();
console.log("firestore :>> ", firestore);
```
**Describe the solution you'd like**
Make it possible to load or install only the parts of the SDK that are really needed (like the new version of the js client sdk => https://github.com/firebase/firebase-js-sdk)
**Describe alternatives you've considered**
I tried to add only parts of SDK we need, e.g.
```js
import { initializeApp } from "firebase-admin/lib/firebase-namespace";
const app = initializeApp();
console.log("app :>> ", app);
const firestore = app.firestore();
console.log("firestore :>> ", firestore);
```
but this gives the same bundle size and it does not work, even when compiling with `tsc`: When running via `node main.js` it gives this:
```bash
/some/path/main.js:6
var app = (0, firebase_namespace_1.initializeApp)();
^
TypeError: (0 , firebase_namespace_1.initializeApp) is not a function
```
贡献指南
调研方向
从导入 firebase-admin 和替代入口 firebase-admin/lib/firebase-namespace 的 TypeScript 示例开始,然后使用 esbuild 复现报告中的 bundle,并检查生成的 main.js。当 SDK 只能加载所需部分,且生成的 bundle 在不破坏初始化或 Firestore 使用的情况下明显更小时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- aws, nodejs, typescript
- 领域
- build-system, cloud, performance
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100