firebase / firebase/firebase-admin-node
CJS vs ESM import issue?
- 主要语言
- TypeScript
- 星标
- 1.7k
- 派生
- 419
- 平均合并
- 3 天 10 小时
- 30 天内合并 PR
- 16
描述
### [READ] Step 1: Are you in the right place?
Yes
### [REQUIRED] Step 2: Describe your environment
* Operating System version: MacOS 15.4.1
* Firebase SDK version: firebase-admin 12.5.0
* Firebase Product: storage
* Node.js version: 20.13.1
* NPM version: 10.8.0
### [REQUIRED] Step 3: Describe the problem
Basically what happened [here](https://github.com/firebase/firebase-admin-node/discussions/2639). It's just there has been no answer to that, only workaround, so I post it here.
Happened to me when importing:
```ts
import type { File } from "@google-cloud/storage";
```
It says:
```console
TS2322: Type
import("/WebstormProjects/firebase/functions/node_modules/@google-cloud/storage/build/cjs/src/file").File
is not assignable to type
import("/WebstormProjects/firebase/functions/node_modules/@google-cloud/storage/build/esm/src/file", { with: { "resolution-mode": "import" } }).File
Property #private in type File refers to a different member that cannot be accessed from within type File
```
#### Steps to reproduce:
Create Firebase Cloud Functions project using typescript and ESM.
#### Relevant Code:
tsconfig:
```json
"module": "Node16",
"moduleResolution": "Node16",
"target": "es2020",
```
贡献指南
调研方向
首先,在使用 ESM、Node.js 20.13.1、firebase-admin 12.5.0 以及所示 Node16 tsconfig 的 Firebase Cloud Functions TypeScript 项目中复现报告的赋值错误。比较 @google-cloud/storage 的 CJS 和 ESM File 类型,以及 issue 中链接的讨论;当原因和适当的项目级解决方案确定后,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- node.js, typescript
- 领域
- backend, cloud
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 30/100