-
Notifications
You must be signed in to change notification settings - Fork 895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: Make Firebase SDK compatible with Angular 10 #3315
Comments
@naveedahmed1 Your issue is interesting to me, since I'm working on a Firebase web app that only uses ES modules. I think it already is:
I'm using Vite for development. It picks the
However, here is where my problems start. The above leaves This works:
..but if I do so, I cannot take Firebase UI from Firebase 7.15.5 |
@naveedahmed1 I notice you changed the title. Would you care to shed more light, why you think Firebase is not "released as ES2015 module"? My problems are already explained here: firebase/firebaseui-web#612 Firebase employees: please help keeping the issues tidy. |
The angularfire ticket explains it in more detail:
I'm no expert in this field, but it does sound like this lib has to change something to be able to conform to the Angular way of doing stuff. APF (Angular Package Format) is explained here: https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit It expects UMD instead of CJS (or commonJS) as James Daniels (Whose also a Firebase engineer) explains in the comment: angular/angularfire#2478 (comment) But true, maybe the title should be FR: Release as APF compatible module. |
We are also attempting to import into an Nativescript-angular application with the same errors as above. We have tried to use the ngcc file as a work around with no such luck. Any movement to move towards UMD would be much appreciated as @jamesdaniels suggests. |
It would be interesting to hear some thoughts from the core team if this is possible? If this makes sense? If this is in the real of possibilities ? If this is something that can be inplace for next release? Or is this just a dream and we should search out a work around? |
Changed the title of the issue for clarity. To sum up the state of the issue so far:
|
Here are the errors that I am seeing: WARNING in /node_modules/@angular/fire/__ivy_ngcc__/fesm2015/angular-fire.js depends on 'firebase/app'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
WARNING in /node_modules/firebase/auth/dist/index.esm.js depends on '@firebase/auth'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
WARNING in /node_modules/firebase/app/dist/index.cjs.js depends on '@firebase/app'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
WARNING in /node_modules/firebase/performance/dist/index.esm.js depends on '@firebase/performance'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies This error message from Angular points to this docs page: I think that the Angular CLI is actually looking for the However, I think that it falls back to The repo is on a recent version of Rollup However, this repo is using
From https://www.npmjs.com/package/rollup-plugin-node-resolve: As that warning states, the package has been renamed to
ExampleIf I change the import in import { apps, initializeApp, registerVersion } from 'firebase/app'; To: import { apps, initializeApp, registerVersion } from 'firebase/app/dist/index.esm.js'; That file contains: import firebase from '@firebase/app';
export { default } from '@firebase/app';
var name = "firebase";
var version = "7.17.1";
/**
* @license
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
firebase.registerVersion(name, version, 'app');
//# sourceMappingURL=index.esm.js.map The build gives this error: "export 'apps' was not found in 'firebase/app/dist/index.esm.js'
at HarmonyImportSpecifierDependency._getErrors (/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:109:11)
at HarmonyImportSpecifierDependency.getErrors (/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:68:16)
at Compilation.reportDependencyErrorsAndWarnings (/node_modules/webpack/lib/Compilation.js:1463:22)
at /node_modules/webpack/lib/Compilation.js:1258:10
at AsyncSeriesHook.eval [as callAsync] (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:40:1)
at AsyncSeriesHook.lazyCompileHook (/node_modules/tapable/lib/Hook.js:154:20)
at Compilation.finish (/node_modules/webpack/lib/Compilation.js:1253:28)
at /node_modules/webpack/lib/Compiler.js:672:17
at _done (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
at eval (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:106:22)
at /node_modules/webpack/lib/Compilation.js:1185:12
at /node_modules/webpack/lib/Compilation.js:1097:9
at processTicksAndRejections (internal/process/task_queues.js:79:11)
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
"export 'initializeApp' was not found in 'firebase/app/dist/index.esm.js'
...
"export 'registerVersion' was not found in 'firebase/app/dist/index.esm.js'
...
"export 'registerVersion' was not found in 'firebase/app/dist/index.esm.js'
... PS. The rollup-plugin-commonjs package ( |
On more piece of possibly confusing data... If I change it to the following bogus import: import { apps, initializeApp, registerVersion } from 'firebase/app/joe'; I get these errors: ERROR in ./node_modules/@angular/fire/__ivy_ngcc__/fesm2015/angular-fire.js
Module not found: Error: Can't resolve 'firebase/app/joe' in '/node_modules/@angular/fire/__ivy_ngcc__/fesm2015'
resolve 'firebase/app/joe' in '/node_modules/@angular/fire/__ivy_ngcc__/fesm2015'
Parsed request is a module
using description file: /node_modules/@angular/fire/package.json (relative path: ./__ivy_ngcc__/fesm2015)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
looking for modules in
using description file: /package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: /package.json (relative path: ./firebase/app/joe)
no extension
Field 'browser' doesn't contain a valid alias configuration
/firebase/app/joe doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
/firebase/app/joe.ts doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
/firebase/app/joe.tsx doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
/firebase/app/joe.mjs doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/firebase/app/joe.js doesn't exist
as directory
/firebase/app/joe doesn't exist From that, it appears to be looking at the
The APF v10 doc doesn't mention the I'll try to get an Angular CLI expert to weigh in on this soon... |
OK, I got word from the Angular CLI team that:
So indeed, my second post appears to have identified the issue. Is it possible to switch the This shouldn't break NodeJS server-side applications at all. |
@hsubox76 The recommendations on packaging node modules for both ESM and CommonJS/UMD use are here. I know some of Firebase team are looking into those. My hope is that the packaging will follow them, at some point. I would also appreciate it if changes to packaging would not be done with Angular or any other single client in mind, as this issue implies, but the node.js standard. Then, all clients would be pleased. |
@akauppi based on those NodeJS recommendations, it appears fine for the It also suggests that the |
any news on a fix for this problem? |
This PR in progress will hopefully address the issue: #3932 |
Fixed with Firebase JS SDK v8. AngularFire will support in |
I still get the "\app.module.ts depends on '@angular/fire/firestore'. CommonJS or AMD dependencies can cause optimization bailouts." warning even after updating AngularFire to 6.0.4 |
Same for me |
This appears to be a false positive with ngcc, I don't see any indications that anything is built wrong despite the warning. It seems NG 11 isn't warning either, so I think it's a bug on the ngcc side angular/angularfire#2565 (comment) |
Describe your environment
Describe the problem
This issue is related to angular/angularfire#2478 reported in
angularfire
repo.Google advises against using
CommonJS
modules because it can impact the tree-shaking of application as explained here https://web.dev/commonjs-larger-bundles/I would therefore request you to please release this plugin as es2015 module so that the production builds are properly tree-shaken.
Thank you
The text was updated successfully, but these errors were encountered: