Skip to content

Commit

Permalink
feat(firebase-v8): updated code to work with Firebase v8+
Browse files Browse the repository at this point in the history
  • Loading branch information
lupas committed Oct 28, 2020
1 parent b26768c commit 4ae48b5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## Quick Setup

Make sure you are using the newest version of Nuxt and have Firebase installed in your project.
Make sure you are using the newest version of Nuxt and have Firebase >8.0.0 installed in your project.

```bash
yarn add firebase # OR npm i firebase
Expand Down
12 changes: 8 additions & 4 deletions docs/content/en/community/migrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ In v7 we introduce a major overhaul of how you access the individual Firebase se

Reason for the renamings is to reduce confusion by sticking to the official naming convention of Firebase.

### 1 - Renamings of injected services
### 1 - Install Firebase JS SDK v8+

Nuxtjs/Firebase v7 now requires the Firebase JS SDK greather than v8.0.0 installed. Make sure to update your dependencies accordingly.

### 2 - Renamings of injected services

Search your entire project and replace all $fireFoo injections according to the table:

Expand All @@ -30,7 +34,7 @@ Search your entire project and replace all $fireFoo injections according to the
| $fireAnalytics | $fire.analytics |
| $fireConfig | $fire.remoteConfig |

### 2 - Renaming of Firebase module/object
### 3 - Renaming of Firebase module/object

Search your entire project and replace all $fireFooObj injections according to the table:

Expand All @@ -46,7 +50,7 @@ Search your entire project and replace all $fireFooObj injections according to t
| $fireAnalyticsObj | $fireModule.analytics |
| $fireConfigObj | $fireModule.remoteConfig |

### 3 - Renamed `realtimeDb` to `database`
### 4 - Renamed `realtimeDb` to `database`

To stick to the Firebase naming convention we renamed the key for the Realtime Database service configuration from `realtimeDb` to `database`.

Expand All @@ -63,7 +67,7 @@ services: {
}
```

### 4 - Removed `movePluginBeforeAuthHelper`
### 5 - Removed `movePluginBeforeAuthHelper`

The helper function `movePluginBeforeAuthHelper` has been removed.

Expand Down
2 changes: 1 addition & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function (moduleOptions) {
validateConfigKeys(options, currentEnv)

// Assign some defaults
options.services.app = Object.assign({ static: !options.lazy }, options.services.app)
options.services.app = Object.assign({ static: false }, options.services.app)
for (const service in options.services) {
if (options.services[service] === true) {
// If a service is enabled always set an object
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/services/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

export default async function createApp(config, {res}) {
<%= (statement = options.writeImportStatement(options))
&& `const firebase = ${statement}`
&& `const firebaseModule = ${statement}`
%>
const firebase = firebaseModule.default

<% if (typeof options.sessions === 'object') { %>
/*************************************************
Expand Down
5 changes: 0 additions & 5 deletions lib/utils/template-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ function writeImportStatement (options, serviceMapping, staticOnly = false) {
if (!useStaticImport) {
return
}

if (serviceMapping.id === 'app') {
return `import * as firebase from ${importPath}`
}

return `import ${importPath}`
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
"core-js": "3",
"cz-conventional-changelog": "latest",
"eslint": "^7.12.0",
"firebase": "^7.24.0",
"firebase": "^8.0.0",
"husky": "^4.3.0",
"jest": "^26.6.1",
"nuxt": "^2.14.7",
"proxy-mock-js": "^1.0.3",
"standard-version": "latest"
},
"peerDependencies": {
"firebase": "^7.24.0",
"firebase": "^8.0.0",
"nuxt": "^2.14.7"
},
"publishConfig": {
Expand Down

0 comments on commit 4ae48b5

Please sign in to comment.