react-workspaces / react-workspaces-playground

⚛️ 🐈 Zero Config Create-React-App Monorepos with Yarn Workspaces, Lerna and React Storybook.
https://react-workspaces.github.io/react-workspaces-playground/
764 stars 128 forks source link

Doesn't work with Firebase #10

Closed marcelmika closed 4 years ago

marcelmika commented 5 years ago

First, thanks for a great lib! We almost made it work until we had to include Firebase as a dependency.

cd packages/apps/app-one
yarn add firebase@6.2.0

As you can see here: https://www.npmjs.com/package/firebase#npm-bundler-browserify-webpack-etc you simply import a firebase package:

// In your code, you can access Firebase using:
var firebase = require('firebase');
var app = firebase.initializeApp({ ... });

// If you are using ES6 imports or TypeScript:
import * as firebase from 'firebase';
var app = firebase.initializeApp({ ... });

Unfortunately, when we do it we get the following error:

TypeError: util.inherits is not a function

Screen Shot 2019-06-17 at 14 24 41

Also, the console prints a couple of warnings:

Screen Shot 2019-06-17 at 14 25 36

We are not having this issue when we use a standard CRA.

F1LT3R commented 5 years ago

Do you have a repo with this setup that I can look at?

marcelmika commented 5 years ago

Sure, check the feature/firebase branch: https://github.com/marcelmika/react-workspaces-playground/tree/feature/firebase

Here's the diff: https://github.com/react-workspaces/react-workspaces-playground/compare/master...marcelmika:feature/firebase

F1LT3R commented 5 years ago

It seems like a Webpack issue. If you use the same version of CRA w/o react-workspaces-playground, does firebase still have the same issue? (Ie: possible incompatible versions of Create React App and Firebase)

WayneEllery commented 5 years ago

I’m having the same issue. Firebase works with CRA w/o react-workspaces-playground

F1LT3R commented 4 years ago

@marcelmika - I get a lot of errors when I try to run yarn on your repo. I don't get these with the normal React Workspaces Playground repo that is currently on master.

Do you have a repo where this is working with CRA-only?

When I try to run your code from yarn start in app-one, I see your util error, but I also see a firebase dependency is missing.

CleanShot 2019-12-22 at 23 15 33@2x

CleanShot 2019-12-22 at 23 16 26@2x

F1LT3R commented 4 years ago

Things I tried that did not work:

  1. Installing latest Firebase
  2. Removing node_modules and yarn.lock then re-installing
F1LT3R commented 4 years ago

I'm able to get a different set of errors when using hoisting for firebase in the root workspace package.json. I'm thinking there's a conflict that we can get around by hoisting correctly. Updating the to latest CRA may help.

CleanShot 2019-12-22 at 23 42 18@2x
F1LT3R commented 4 years ago

I will try to check Firebase again soon. It may "just work" after updating to latest React v3.3.0. That update work is being done here: https://github.com/react-workspaces/react-workspaces-playground/pull/21