How deploy React+Vite+Firebase on Cloudflare?

I’m deploying a project on Cloudflare, everything was going well until I installed Firebase to do the user authentication part. The following error appears in the cloudflare deployment log:

 02:31:26.714[vite]: Rollup failed to resolve import "firebase/app" from "/opt/buildhome/repo/src/services/firebaseConfig.jsx".
02:31:26.714 This is most likely unintended because it can break your application at runtime.
02:31:26.715 If you do want to externalize this module explicitly add it to
02:31:26.715 `build.rollupOptions.external` 

And when I explicitly add the module to ‘build.rollupOptions.external’ ( I don’t know what it does ) the application even completes the build but when I enter the site console the following error appears:

Uncaught TypeError: Failed to resolve module specifier "firebase/auth". Relative references must start with either "/", "./", or "../"

Can anyone help me solve this problem in the best way?