Skip to content

Add Firestore, initializeFirestore, getFirestore to Firestore lite #3108

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

Merged
merged 19 commits into from
May 29, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

This adds the wiring for Firestore, initializeFirestore, getFirestore in the firestore/lite build.

Comment on lines 18 to 19
import firebase from '@firebase/app';
import { FirebaseNamespace } from '@firebase/app-types';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning to make Firestore lite work with the existing SDK? If not, you should take dependency on @firebase/app-next and @firebase/app-types-next instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using @firebase/app-next to register components:

import { _registerComponent } from '@firebase/app-next';

_registerComponent(new Component(...))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not planning on making this work with the existing SDK. Apart from added confusion, there is no real benefit as far as I can tell.

@@ -0,0 +1,104 @@
/**
* @license
* Copyright 2017 Google LLC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update license

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 22 to 23
import { FirebaseApp } from '@firebase/app-types';
import { FirebaseService } from '@firebase/app-types/private';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should depend on @firebase/app-types-exp instead.
It currently doesn't define a FirebaseService interface, I'm adding it in https://github.com/firebase/firebase-js-sdk/pull/3112/files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added TODO and removed FirebaseService.

"prepare": "yarn build"
},
"lite": "dist/lite/index.node.cjs.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should lite has its own package.json, so people can import using import {...} from '@firebase/firestore/lite'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

json({ preferConst: true })
];

const nodeBuilds = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you will add browser builds eventually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This slows down development for now. Added TODO.

@schmidt-sebastian
Copy link
Contributor Author

@Feiyang1 The binary size presubmit requires me to add the Lite build to yarn build. I am not super stoked about this, but also don't mind that much. Just wanted to get your thoughts.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 27, 2020

Binary Size Report

Affected SDKs

  • @firebase/firestore/lite

    Type Base (7de1a7c) Head (b8680db) Diff
    main ? 6.51 kB ? (?)

Test Logs

{ apiKey: 'fake-api-key', projectId: 'test-project' },
'test-app-initializeFirestore'
);
initializeFirestore(app, { host: 'localhost', ssl: false });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget to assert that the setting object on the Firestore instance equals the input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only meant to make sure that this doesn't throw. There is no API to read the settings. I added an instanceOf check to make this more like a proper test.

"@firebase/app-types": "0.x"
"@firebase/app-exp": "0.x",
"@firebase/app-types": "0.x",
"@firebase/app-types-ext": "0.x"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not add -exp packages in dependencies or peerDependencies, because they don't really exist on npm. For now, can you just suppress the eslint errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"build:deps": "lerna run --scope @firebase/'{app,firestore}' --include-dependencies build",
"build:console": "node tools/console.build.js",
"build:exp": "rollup -c rollup.config.exp.js",
"build:exp": "rollup -c rollup.config.exp.js",
"build:lite": "lerna run --scope @firebase/app-exp --include-dependencies build && rollup -c rollup.config.lite.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to add a new script build:lite:deps that builds @firebase/app-exp and deps, while keeping this script simply executing rollup. During dev, you execute build:lite:deps once to compile all deps, then use build:lite for quick firestore rebuild.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is not applicable if I use devDependencies? At least the PR builds without it. I am learning by doing here :)

@schmidt-sebastian schmidt-sebastian force-pushed the mrschmidt/initializefirestore branch from e25903a to 804fe94 Compare May 28, 2020 00:25
@schmidt-sebastian schmidt-sebastian merged commit 6e6dbe2 into master May 29, 2020
@firebase firebase locked and limited conversation to collaborators Jun 29, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/initializefirestore branch July 9, 2020 17:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants