mikkopaderes / ember-firebase-service

Exposes a service that's a direct representation of Firebase
MIT License
4 stars 2 forks source link

Getting error "Error: Cannot instantiate firebase-database - be sure to load firebase-app.js first." #16

Closed alexmasita closed 5 years ago

alexmasita commented 5 years ago

Getting the following error when I try to build my app after upgrading this addon via the ember-cloud-firestore-adapter:

App is being served by FastBoot
TypeError: Cannot read property 'INTERNAL' of undefined
    at /var/folders/q5/0j0lj_2d3f7fl0b5q2zq6sfc0000gn/T/broccoli-87000aEbTt56DYcBg/out-618-broccoli_persistent_filter_replace_filter/assets/node_modules/firebase/firebase-database.js:1:1
    at /var/folders/q5/0j0lj_2d3f7fl0b5q2zq6sfc0000gn/T/broccoli-87000aEbTt56DYcBg/out-618-broccoli_persistent_filter_replace_filter/assets/node_modules/firebase/firebase-database.js:1:1
    at /var/folders/q5/0j0lj_2d3f7fl0b5q2zq6sfc0000gn/T/broccoli-87000aEbTt56DYcBg/out-618-broccoli_persistent_filter_replace_filter/assets/node_modules/firebase/firebase-database.js:1:1
    at /var/folders/q5/0j0lj_2d3f7fl0b5q2zq6sfc0000gn/T/broccoli-87000aEbTt56DYcBg/out-618-broccoli_persistent_filter_replace_filter/assets/node_modules/firebase/firebase-database.js:1:1
    at Script.runInContext (vm.js:133:20)
    at VMSandbox.eval (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services/node_modules/fastboot/src/vm-sandbox.js:14:16)
    at /Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services/node_modules/fastboot/src/ember-app.js:156:15

It appears this issue is related to the refactor you did around creating fastboot shims on the firebase libraries as when I revert the code to the code on the previous version of this addon, the fastboot server loads without errors. I suspect that there needs to a new way of importing additional libraries other than the documented way below?

'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function (defaults) {
  const app = new EmberApp(defaults, {
    ...
  });

  ...
  // Maybe we need to shim these as well?
  app.import('node_modules/firebase/firebase-database.js');
  app.import('node_modules/firebase/firebase-functions.js');
  app.import('node_modules/firebase/firebase-storage.js');

  return app.toTree();
};
mikkopaderes commented 5 years ago

It is up to the user to shim the firebase features that they want to use. This addon only shims firebase-app as it is what's required to firebase to run.

mikkopaderes commented 5 years ago

What is the contents of your package.json?

alexmasita commented 5 years ago

I believe there is a way provided by ember that allows enabling shimming in the ember-cli-build. I have tested it and seems to work. I have submitted a pull request for the same to update your read me. Let me know if you still need to see the contents of my package.json. Thank you.

mikkopaderes commented 5 years ago

Issue resolved. Feel free to reopen if necessary. Thanks! 😃