firebase / firebase-admin-node

Firebase Admin Node.js SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
1.6k stars 358 forks source link

ES6 Suport Broken #2543

Open bassrock opened 2 months ago

bassrock commented 2 months ago

Describe your environment

Steps to reproduce:

When using firebase sdk in an ES6 environment where the tsconfig looks like:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "ESNext",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "removeComments": true,
    "esModuleInterop": true,
    "noEmitOnError": false,
    "sourceMap": true,
    "inlineSources": true,
    "sourceRoot": "/",
    "declaration": true,
    "noEmitHelpers": true,
    "importHelpers": true
  }
}

and the package.json is set to type: "module" you get the following error with the long module:

../../node_modules/.pnpm/long@5.2.3/node_modules/long/umd/index.d.ts:1:18 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead.

Relevant Code:

I believe the issue may be this line https://github.com/firebase/firebase-admin-node/blob/7463d1cff603ebe3b918e64c0b05328ca5888b05/src/remote-config/condition-evaluator-internal.ts#L29 but I am not totally sure.

google-oss-bot commented 2 months ago

I found a few problems with this issue:

elliottAtTreatment commented 1 month ago

My entire team and i also ran into this issue. Been present for at least several weeks if not much longer. It occurs in all our applications using typescript, node.js, and a firebase-admin import.

We now have been resorting to adding: "skipLibCheck": true

tsconfig: { "compilerOptions": { "rootDir": "src", "outDir": "dist", "target": "es2022", "module": "NodeNext", "sourceMap": true, "allowJs": false, "alwaysStrict": true, "resolveJsonModule": true, "noImplicitAny": true, "strictNullChecks": true, "esModuleInterop": true, "skipLibCheck": true } }

lahirumaramba commented 1 month ago

Hey folks, thanks for reporting this issue! I am having trouble reproducing this... my code seem to build on NodeJS 20.11 with ES6. Are you able to provide us a minimal repro? Thanks!