Skip to content

Partial imports with rollup failing #47

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

Closed
hville opened this issue Jun 12, 2017 · 8 comments
Closed

Partial imports with rollup failing #47

hville opened this issue Jun 12, 2017 · 8 comments

Comments

@hville
Copy link

hville commented Jun 12, 2017

Following up on #45 and on @jshcrowthe's comment:

Use case: just importing the database layer to develop and unit test individual modules that need a common async data store. They will likely eventually be used in the browser but development, unit testing, and packaging is just so much easier and faster in node.

//app.js
import * as firebase from './node_modules/firebase/app'
import './node_modules/firebase/database'
firebase.initializeApp({databaseURL: 'x.y.z'}, 'local').database().goOffline()
  1. using rollup in the CLI >rollup -o app.bld.js -f cjs app.js
     'initializeApp' is not exported by 'node_modules\firebase\app.js'
     Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
  1. using rollup in a script with the nodeResolve() and commonjs({include: 'node_modules/**'}) plugins
    'initializeApp' is not exported by 'node_modules\firebase\app.js'
  1. Tried importing from ./node_modules/firebase/firebase-app but being build for the browser I get a navigator error in node

  2. I also tried many a few combinations directly in the firebase/app/ folder with browserify to get an intermediate build that would be easier to consume but the build system looks like it was hacked to suit babel.

I understand I am trying to use the database component in a way that is not the intended typical use but I thought that if there were less frictions in just using the firebase toolset it would be much easier to get there progressively.

@google-oss-bot
Copy link
Contributor

Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.

@jsayol
Copy link
Contributor

jsayol commented Jun 12, 2017

FYI, it works fine if you change your imports to:

import * as firebase from 'firebase/app';
import 'firebase/database';

@hville
Copy link
Author

hville commented Jun 12, 2017

Hi @jsayol. Could you clarify what rollup plugins and/or settings you are using? If used directly I get 'firebase/app' is imported by app.js, but could not be resolved – treating it as an external dependency. It works but only because firebase never gets bundled at all and the require is left there intact. If I used the rollup resolve plugin and/or the commonjs module I get the same errors listed above.

Here is my environment:

  • windows 10
  • rollup 0.42.0
  • firebase 4.1.2

@anlexN
Copy link

anlexN commented Aug 20, 2017

i have also some same problem!

1
default
2

@jshcrowthe
Copy link
Contributor

@hville, @anlexN if either of you could provide me a small repo highlighting the issue I'd be happy to take a look.

@anlexN
Copy link

anlexN commented Oct 5, 2017

@jshcrowthe , can you showcase firebase how to bind rollupjs?

@cspanring
Copy link

@jshcrowthe there is an issue filed on the rollup repo, linking a MCVE to reproduce the underlying issue.

@jshcrowthe
Copy link
Contributor

Closing this due to inactivity and since it seems to be an issue w/ the rollup lib and not Firebase

@firebase firebase locked and limited conversation to collaborators Oct 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants