Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Using angularfire2 with firebase #3

Closed
shlomiassaf opened this issue Sep 18, 2016 · 2 comments
Closed

Using angularfire2 with firebase #3

shlomiassaf opened this issue Sep 18, 2016 · 2 comments

Comments

@shlomiassaf
Copy link
Contributor

shlomiassaf commented Sep 18, 2016

Hi,

Trying to ionic serve my code (using beta.12 branch for app-base and tabs app template) I get this error:

[01:54:08]  bundle failed:  Error: Module app/node_modules/angularfire2/node_modules/firebase/firebase-node.js does not export auth (imported by app/node_modules/angularfire2/auth/firebase_sdk_auth_backend.js)

It appears to be an error in the rollup bundling process (ngc completes ok).
Not sure if it's a problem with the integration of the bundle of angularfire2 with rollup or some config issue for rollup...

removing all imports of angularfire2 (and code that uses it) and the everything is fine.

Thanks, Shlomi.

@shlomiassaf
Copy link
Contributor Author

Ok, to workaround this I had to provide a custom config for rollup and skip firebase

const rollupNG2 = require('@ionic/app-scripts/dist/plugins/rollupNG2').rollupNG2;
const nodeResolve = require('rollup-plugin-node-resolve');

// https://github.com/rollup/rollup/wiki/JavaScript-API

module.exports = {
  /**
   * entry: The bundle's starting point. This file will
   * be included, along with the minimum necessary code
   * from its dependencies
   */
  entry: '.tmp/app/main.prod.js',

  /**
   * sourceMap: If true, a separate sourcemap file will
   * be created.
   */
  sourceMap: true,

  /**
   * format: The format of the generated bundle
   */
  format: 'iife',

  /**
   * dest: the output filename for the bundle in the buildDir
   */
  dest: 'main.es6.js',

  /**
   * plugins: Array of plugin objects, or a single plugin object.
   * See https://github.com/rollup/rollup/wiki/Plugins for more info.
   */
  plugins: [
    rollupNG2(),
    nodeResolve({
      module: true,
      jsnext: true,
      main: true,
      browser: true,
      extensions: ['.js'],
      skip: [ 'firebase' ]
    })
  ]

};

And provide it in the index.html

This is of course a workaround... not a solution.

@adamdbradley
Copy link
Contributor

I don't think this is related to ionic-app-scripts, but something in AngularFire2. But glad you were able to come up with a solution. Thanks

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

No branches or pull requests

2 participants