Robin Claes
Robin Claes

Reputation: 502

Cannot globally export firebase

When using aurelia-cli, in a newly made project, I'm trying to include firebase in my bundle using the following code:

  {
    "name": "firebase",
    "path": "../node_modules/firebase",
    "main":"firebase",
    "exports": "firebase"
  }

Based on their documentation, this should make firebase globally available in my app (similar to $for jQuery).

What's causing this not to work?

Upvotes: 0

Views: 202

Answers (1)

Robinson Collado
Robinson Collado

Reputation: 316

In your main.js, try the following:

import firebase from 'firebase';

export function configure(aurelia) {

  ...

  firebase.initializeApp({
    apiKey: 'your_api_key',
    authDomain: 'your_auth_domain',
    databaseURL: 'your_database_url',
    storageBucket: 'your_storage_bucket'
  });

  aurelia.start().then(() => aurelia.setRoot());
}

In app.js:

// Import firebase if the project was created using the Aurelia-CLI
// If you're using the Aurelia Esnext-Skeleton, you don't have to import firebase
import firebase from 'firebase';

export class App {
  constructor() {
    this.some_ref = firebase.database().ref('some_path');
  }
}

Upvotes: 2

Related Questions