Skip to content

firebase doesn't play nicely with yarn install --flat #546

Closed
@zevdg

Description

@zevdg

[REQUIRED] Describe your environment

  • Operating System version: Linux 4.15.7 (Solus 3)
  • Firebase SDK version: npm [email protected]
  • Firebase Product: firestore

[REQUIRED] Describe the problem

I was trying to follow best practices with my web app and ran yarn install --prod --flat to make sure that I wasn't using delivering multiple copies of the same libraries to my clients. I found several libraries with conflicts and they were all being pulled in by firebase. Specifically: minimist, readable-stream, isarray, process-nextick-args, string_decoder, assert-plus, extsprintf, glob, through2, vinyl, clone, clone-stats, replace-ext, glob-parent, is-glob, is-extglob, kind-of, and is-number.

Some further debugging...

$ npm ls --prod minimist readable-stream isarray process-nextick-args string_decoder assert-plus extsprintf glob through2 vinyl clone clone-stats replace-ext glob-parent is-glob is-extglob kind-of is-number
[email protected] /home/user/workspace/site
└─┬ [email protected]
  ├─┬ @firebase/[email protected]
  │ └─┬ [email protected]
  │   ├─┬ [email protected]
  │   │ ├─┬ [email protected]
  │   │ │ └── [email protected]
  │   │ ├─┬ [email protected]
  │   │ │ └─┬ [email protected]
  │   │ │   └── [email protected]  deduped
  │   │ ├─┬ [email protected]
  │   │ │ └── [email protected]
  │   │ ├─┬ [email protected]
  │   │ │ └─┬ [email protected]
  │   │ │   ├── [email protected]
  │   │ │   ├─┬ [email protected]
  │   │ │   │ ├── [email protected]
  │   │ │   │ ├── [email protected]
  │   │ │   │ └─┬ [email protected]
  │   │ │   │   ├── [email protected]
  │   │ │   │   └── [email protected]  deduped
  │   │ │   └─┬ [email protected]
  │   │ │     ├── [email protected]
  │   │ │     ├─┬ [email protected]
  │   │ │     │ └── [email protected]
  │   │ │     └─┬ [email protected]
  │   │ │       └── [email protected]
  │   │ ├─┬ [email protected]
  │   │ │ └── [email protected]
  │   │ └─┬ [email protected]
  │   │   └─┬ [email protected]
  │   │     ├── [email protected]
  │   │     ├── [email protected]
  │   │     └── [email protected]
  │   └─┬ [email protected]
  │     └── [email protected]
  └─┬ @firebase/[email protected]
    └─┬ [email protected]
      ├─┬ [email protected]
      │ └─┬ [email protected]
      │   ├── [email protected]
      │   ├── [email protected]
      │   └── [email protected]
      ├─┬ [email protected]
      │ ├── [email protected]
      │ ├── [email protected]
      │ ├─┬ [email protected]
      │ │ ├── [email protected]
      │ │ └── [email protected]  deduped
      │ └── [email protected]
      └─┬ [email protected]
        ├─┬ [email protected]
        │ └── [email protected]  deduped
        ├─┬ [email protected]
        │ ├── [email protected]
        │ ├─┬ [email protected]
        │ │ └─┬ [email protected]
        │ │   └── [email protected]
        │ ├─┬ [email protected]
        │ │ ├─┬ [email protected]
        │ │ │ └─┬ [email protected]
        │ │ │   └─┬ [email protected]
        │ │ │     ├─┬ [email protected]
        │ │ │     │ └── [email protected]  deduped
        │ │ │     ├─┬ [email protected]
        │ │ │     │ └── [email protected]  deduped
        │ │ │     └─┬ [email protected]
        │ │ │       ├─┬ [email protected]
        │ │ │       │ └── [email protected]
        │ │ │       └── [email protected]
        │ │ ├─┬ [email protected]
        │ │ │ └── [email protected]
        │ │ ├── [email protected]
        │ │ ├─┬ [email protected]
        │ │ │ └── [email protected]  deduped
        │ │ ├── [email protected]
        │ │ └─┬ [email protected]
        │ │   ├─┬ [email protected]
        │ │   │ ├─┬ [email protected]
        │ │   │ │ └── [email protected]  deduped
        │ │   │ └─┬ [email protected]
        │ │   │   └── [email protected]
        │ │   ├── [email protected]
        │ │   └─┬ [email protected]
        │ │     └── [email protected]  deduped
        │ ├─┬ [email protected]
        │ │ └── [email protected]  deduped
        │ └─┬ [email protected]
        │   └─┬ [email protected]
        │     ├── [email protected]
        │     └── [email protected]
        ├─┬ [email protected]
        │ ├── [email protected]  deduped
        │ └─┬ [email protected]
        │   ├── [email protected]
        │   ├── [email protected]
        │   └── [email protected]
        ├─┬ [email protected]
        │ └── [email protected]  deduped
        ├─┬ [email protected]
        │ └── [email protected]  deduped
        ├─┬ [email protected]
        │ └── [email protected]
        ├── [email protected]  deduped
        ├── [email protected]  deduped
        ├─┬ [email protected]
        │ └── [email protected]  deduped
        └─┬ [email protected]
          ├── [email protected]
          ├── [email protected]
          └── [email protected]

As you can see, all of these conflicts are getting pulled in due to grpc getting pulled in by @firebase/firestore and lcov-result-merger getting pulled in by @firebase/messaging.

The grpc package ultimately gets tree-shaken out on non-node platforms, so it really isn't a problem. However, since it's listed as a normal dependency, yarn can't know that it will ultimately get excluded from the build and so it gets included in the --flat resolution. I'm not sure what the best solution to this problem is, but I suspect the easiest thing would be to make it an optional dependency.

The lcov-result-merger package appears to have been added as part of this commit by mistake. It's only used as a cli tool during development and it's already included as a dev dependency at the root of the project. I removed it from @firebase/messaging and all the tests still pass.

Steps to reproduce:

#vue isn't necessary to reproduce this.  This was just one of the simplest demos I could find that actually imported firebase as an npm package 
git clone [email protected]:Q42/vuejs-firestore-demo.git 
cd vuejs-firestore-demo
npm upgrade firebase

# then, to see the issue before we get yarn involved
npm ls --prod minimist readable-stream isarray process-nextick-args string_decoder assert-plus extsprintf glob through2 vinyl clone clone-stats replace-ext glob-parent is-glob is-extglob kind-of is-number

# to recreate the issue itself, run
yarn install --prod --flat

Relevant Code:

see reproduction steps

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions