Using Firebase with Cocos Creator Throws Error

Hi,
I’m trying to use Firebase with Cocos Creator v3 & tried with Cocos Creator v2 too. I installed the Firebase through npm

But unfortunately it throws errors

in Cocos Creator v2 using it like
const { initializeApp } = require('firebase/app');
ERROR MSG
Cannot use import statement outside a module

in Cocos Creator v3 using it like
import { initializeApp } from "firebase/app";
const app = initializeApp(firebaseConfig); //on initialise it throws error if remove this line then no error
ERROR MSG
Unexpected export statement in CJS module.

Is it because Firebase node version uses node.js native API which causes Cocos Creator Environment to throw errors?
Do I need to use web compiled version of Firebase having single file to fix this issue?

From what I understand. It’s best to import after the build and before finalizing the apk.

@LukeStapley I wanted it for web version.
To fix the issue may I need to directly download build files like following

https://www.gstatic.com/firebasejs/10.1.0/firebase-app.js
https://www.gstatic.com/firebasejs/10.1.0/firebase-analytics.js
https://www.gstatic.com/firebasejs/10.1.0/firebase-auth.js
https://www.gstatic.com/firebasejs/10.1.0/firebase-firestore.js

and import in the project of cocos creator to use it? these will actually directly expose variables in global space