Skip to content
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

Web V9 #3711

Closed
RaheutRahwana opened this issue Aug 27, 2021 · 1 comment · Fixed by #3724
Closed

Web V9 #3711

RaheutRahwana opened this issue Aug 27, 2021 · 1 comment · Fixed by #3724

Comments

@RaheutRahwana
Copy link

[REQUIRED] Environment info

firebase-tools:
v9.16.6

Platform:
Fedora 34

[REQUIRED] Test case

Open http://localhost:5000/ on browser.

[REQUIRED] Steps to reproduce

firebase init
firebase serve

and open http://localhost:5000/ on browser.

[REQUIRED] Expected behavior

Everything works as it did on version 8

[REQUIRED] Actual behavior

There are some errors like:

Uncaught SyntaxError: Unexpected token 'export' firebase-app.js:1590
Uncaught SyntaxError: Cannot use import statement outside a module firebase-auth.js:1
Uncaught Error: hosting/init-error: Firebase SDK not detected. You must include it before /__/firebase/init.js init.js:1
@davideast
Copy link
Member

davideast commented Sep 1, 2021

There's a bug in our boilerplate files. We'll get it addressed in the next CLI release.

Fix right now

If you want to continue using Firebase off the window you'll need to either continue to use version 8 (not recommended) or upgrade to version 9 compat.

Using compat

<script src="/__/firebase/9.0.0/firebase-app-compat.js"></script>
<script src="/__/firebase/9.0.0/firebase-auth-compat.js"></script>
<script src="/__/firebase/9.0.0/firebase-firestore-compat.js"></script>
<script src="/__/firebase/init.js"></script>
<script>
   const firebaseApp = firebase.initializeApp({ /* Firebase config */ });
   const db = firebaseApp.firestore();
   const auth = firebaseApp.auth();
</script>

Our recommendation

We are recommending using the module based v9 API with a module bundler like webpack or rollup going forward. The v9 SDK is optimized for tree shaking which strips out unused library code and therefore reduces the amount of Firebase code included in your site.

Resources for upgrading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants