Skip to content
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

Modularize functions #3051

Merged
merged 12 commits into from Jun 20, 2020
Merged

Modularize functions #3051

merged 12 commits into from Jun 20, 2020

Conversation

hsubox76
Copy link
Contributor

First draft at modularizing firebase/functions.

packages-exp/functions-exp/package.json Outdated Show resolved Hide resolved
packages-exp/functions-exp/package.json Outdated Show resolved Hide resolved
packages-exp/functions-exp/package.json Outdated Show resolved Hide resolved
packages-exp/functions-exp/src/api.ts Outdated Show resolved Hide resolved
packages-exp/functions-exp/src/api.ts Outdated Show resolved Hide resolved
packages-exp/functions-exp/src/context.ts Outdated Show resolved Hide resolved
packages-exp/functions-exp/src/error.ts Outdated Show resolved Hide resolved
packages-exp/functions-exp/src/index.node.ts Outdated Show resolved Hide resolved
packages-exp/functions-exp/src/service.ts Outdated Show resolved Hide resolved
packages-exp/functions-exp/src/service.ts Outdated Show resolved Hide resolved
@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 20, 2020

Binary Size Report

Affected SDKs

  • @firebase/util

    Type Base (e4babee) Head (2c9044b) Diff
    browser 19.6 kB 19.6 kB -3 B (-0.0%)
    esm2017 17.5 kB 17.5 kB -3 B (-0.0%)
    main 19.6 kB 19.6 kB -3 B (-0.0%)
    module 18.7 kB 18.7 kB -3 B (-0.0%)
  • firebase

    Click to show 14 binary size changes.
    Type Base (e4babee) Head (2c9044b) Diff
    firebase-analytics.js 26.6 kB 26.6 kB -3 B (-0.0%)
    firebase-app.js 19.9 kB 19.9 kB -3 B (-0.0%)
    firebase-database.js 187 kB 187 kB -3 B (-0.0%)
    firebase-firestore.js 287 kB 287 kB -3 B (-0.0%)
    firebase-firestore.memory.js 226 kB 226 kB -3 B (-0.0%)
    firebase-functions.js 9.60 kB 9.60 kB -3 B (-0.0%)
    firebase-installations.js 19.2 kB 19.2 kB -3 B (-0.0%)
    firebase-messaging.js 39.1 kB 39.1 kB -3 B (-0.0%)
    firebase-performance-standalone.es2017.js 72.0 kB 72.0 kB -3 B (-0.0%)
    firebase-performance-standalone.js 47.2 kB 47.2 kB -3 B (-0.0%)
    firebase-performance.js 37.6 kB 37.6 kB -3 B (-0.0%)
    firebase-remote-config.js 37.0 kB 37.0 kB -3 B (-0.0%)
    firebase-storage.js 40.8 kB 40.8 kB -3 B (-0.0%)
    firebase.js 819 kB 819 kB -3 B (-0.0%)

Test Logs

{
'packageDir': [path.resolve(__dirname, '../../'), './'],
devDependencies: true,
peerDependencies: true
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't peerDependencies to be allowed?

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 allows peerDependencies (will not show error on peerDependency import). Are you saying it should not be allowed?

Also this whole rule is a mess for monorepos, it looks like someone has submitted a PR to try to fix it but it has not been looked at yet: import-js/eslint-plugin-import#1650

Copy link
Member

Choose a reason for hiding this comment

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

Right. I meant not allowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed. I thought it would give me errors on imports from @firebase/app-types-exp but I guess it doesn't? I don't know how this rule works anymore.

packages-exp/functions-exp/package.json Outdated Show resolved Hide resolved
packages-exp/functions-exp/package.json Outdated Show resolved Hide resolved
packages-exp/functions-exp/src/callable.test.ts Outdated Show resolved Hide resolved
packages-exp/functions-exp/src/service.ts Outdated Show resolved Hide resolved
packages-exp/functions-exp/test/utils.ts Outdated Show resolved Hide resolved
packages-exp/functions-exp/src/error.ts Outdated Show resolved Hide resolved
* A standard error code that will be returned to the client. This also
* determines the HTTP status code of the response, as defined in code.proto.
*/
readonly code: FunctionsErrorCode,
Copy link
Member

Choose a reason for hiding this comment

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

It should be a simple input parameter without readonly annotation because otherwise it would create a property code on FunctionsError.

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.

*/
readonly details?: unknown
) {
super(code, message || '');
Copy link
Member

Choose a reason for hiding this comment

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

The format for code shoud be service/error-code-string

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.

* The main class for the Firebase Functions SDK.
* @internal
*/
export class FunctionsService {
Copy link
Member

Choose a reason for hiding this comment

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

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.

@@ -66,7 +66,8 @@ export interface StringLike {
}

export interface ErrorData {
[key: string]: StringLike | undefined;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
Copy link
Member

Choose a reason for hiding this comment

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

Can it be unknown?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but to get around an error in line 151 I had to change .toString() to String(), hopefully that's ok.

async function updateField(pkg, fieldName) {
const field = pkg[fieldName];
for (const depName in field) {
if (!depName.includes('@firebase')) continue;
Copy link
Member

Choose a reason for hiding this comment

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

We should update the firebase package as well as packages may depend on it, e.g.@firebase/testing and rxFire

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@hsubox76
Copy link
Contributor Author

I'm going to wait for this week's release to be merged to master, rebase, run package.json version update script, and then merge.

@hsubox76 hsubox76 merged commit d470f49 into master Jun 20, 2020
@@ -0,0 +1,25 @@
{
"name": "@firebase/functions-types-exp",
Copy link
Member

Choose a reason for hiding this comment

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

Can you please make it private?

@firebase firebase locked and limited conversation to collaborators Jul 21, 2020
@hsubox76 hsubox76 changed the title WIP: Modularize functions Modularize functions Aug 21, 2020
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.

None yet

3 participants