-
Notifications
You must be signed in to change notification settings - Fork 897
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
Add API Extractor for @firestore/lite + exp #3657
Conversation
💥 No ChangesetLatest commit: 37c864b Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂 If these changes should be published to npm, you need to add a changeset. This PR includes no changesetsWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Click here to learn what changesets are, and how to add one. Click here if you're a maintainer who wants to add a changeset to this PR |
@@ -1,5 +1,5 @@ | |||
{ | |||
"name": "@firebase/firestore/lite", | |||
"name": "@firebase/firestore-lite", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API Extractor considers this name invalid - looks like one slash is the maximum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Api-extractor doesn't support multiple entry points, so you need to trick it to think that lite is a package instead of a submodule.
(I have a PR to support multiple entry points, but only for documentation and api report)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is invalid even outside of this PR. I get this error from IntelliJ when I turn on JSON schema validation:
String violates the pattern: '^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$'
Inspection info: This inspection checks that JSON files conform to JSON Schemas assigned to them
The pattern seems to allow only one scoped package. Do we need to change it or should I spend some time trying to figure out how to work around this limitation without the name change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name actually doesn't matter, so it can be whatever that's easier for you. We use/
to be consistent with how developer would use the submodules, so I prefer to stay this way. Does it give you any issue other than unpleasant validation error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the following error:
Error: Error parsing /Users/mrschmidt/GitHub/firebase/firebase-js-sdk/packages/firestore/lite/api-extractor.json:
The package name "@firebase/firestore/lite" contains an invalid character: "/"
The build stops after this message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right, api-extractor definitely doesn't like it. You can change it to -
to work around it for now. I'm planning to release a forked version of api-extractor with support for multiple entry points. We will come back to this once that's done.
@@ -136,6 +135,7 @@ | |||
"ora": "4.0.5", | |||
"prettier": "2.0.5", | |||
"protractor": "5.4.2", | |||
"rollup-plugin-copy": "3.3.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rollup-plugin-copy-asset doesn't allow me to move the proto files to dist/lite/src/proto
package.json
Outdated
@@ -66,8 +66,7 @@ | |||
"@changesets/changelog-github": "0.2.6", | |||
"@changesets/cli": "2.9.2", | |||
"@microsoft/api-documenter": "7.8.21", | |||
"@microsoft/api-extractor": "7.9.2", | |||
"@types/mz": "2.7.1", | |||
"@microsoft/api-extractor": "7.8.2-pr1796.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pulls in microsoft/rushstack#1029, which makes this diff about 500 lines smaller (see the revert 609b2b3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh, the commit shows 445 additions and 477 deletions
, so the net gain seems to be 32 lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it 500 lines in terms of changed lines. I can go with the version that doesn't require the custom release if you prefer that (which might make sense especially since we seem to waiting on a lot of other PRs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I created a new PR to merge just this: #3660
package.json
Outdated
@@ -66,8 +66,7 @@ | |||
"@changesets/changelog-github": "0.2.6", | |||
"@changesets/cli": "2.9.2", | |||
"@microsoft/api-documenter": "7.8.21", | |||
"@microsoft/api-extractor": "7.9.2", | |||
"@types/mz": "2.7.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in here twice.
Binary Size ReportAffected SDKs
Test Logs |
609b2b3
to
bedb8d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you planning to do the same for exp?
"extends": "../../../config/api-extractor.json", | ||
"mainEntryPointFilePath": "../dist/lite/firestore/lite/index.d.ts", | ||
"dtsRollup": { | ||
"enabled": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think you will ever need main and lite to share declarations? There is a risk where the same type from main and lite becomes incompatible if they use separate rollup d.ts files - see discussion here. It's probably not a problem for us, since we are already using separate d.ts files for lite and main, but it's good to keep that in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to do that, neither now nor in the future. Most of our types are incompatible with one another (i.e. a DocumentReference that contains a a Lite Firestore is incompatible with a DocumentReference for the main Firestore).
package.json
Outdated
@@ -66,8 +66,7 @@ | |||
"@changesets/changelog-github": "0.2.6", | |||
"@changesets/cli": "2.9.2", | |||
"@microsoft/api-documenter": "7.8.21", | |||
"@microsoft/api-extractor": "7.9.2", | |||
"@types/mz": "2.7.1", | |||
"@microsoft/api-extractor": "7.8.2-pr1796.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh, the commit shows 445 additions and 477 deletions
, so the net gain seems to be 32 lines?
@@ -1,5 +1,5 @@ | |||
{ | |||
"name": "@firebase/firestore/lite", | |||
"name": "@firebase/firestore-lite", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Api-extractor doesn't support multiple entry points, so you need to trick it to think that lite is a package instead of a submodule.
(I have a PR to support multiple entry points, but only for documentation and api report)
@@ -7,14 +7,15 @@ | |||
"description": "The Cloud Firestore component of the Firebase JS SDK.", | |||
"author": "Firebase <[email protected]> (https://firebase.google.com/)", | |||
"scripts": { | |||
"api-report:lite": "(cd lite; api-extractor run --local --verbose)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once this PR is merged, we can generate api reports for multiple entry points together, so you won't generate report for lite and main separately.
It seems it might take a long time to merge though, so I might publish a forked version to npm which we will use. For now, this is okay.
dest: 'dist/lite/src' | ||
}, | ||
{ | ||
// Copy into generated source files to support API Extractor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does API extractor need a different path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The source tree that it uses are the .d.ts generated files in dist/lite/firestore/src, and by default the "proto" dir is missing. I assume that is because we provide d.ts files to begin with and so nothing gets generated.
FWIW, I changed this to only copy the d.ts file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some follow up questions.
I planned to do this in a follow-up to for /exp. I realized that we are not actually blocked because of the behavior differences that I would like to clarify in the API documentation, since the APIs that have different behavior are already implemented twice (e.g. getDoc). I pushed the changes to this PR now since without them the build was broken.
package.json
Outdated
@@ -66,8 +66,7 @@ | |||
"@changesets/changelog-github": "0.2.6", | |||
"@changesets/cli": "2.9.2", | |||
"@microsoft/api-documenter": "7.8.21", | |||
"@microsoft/api-extractor": "7.9.2", | |||
"@types/mz": "2.7.1", | |||
"@microsoft/api-extractor": "7.8.2-pr1796.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it 500 lines in terms of changed lines. I can go with the version that doesn't require the custom release if you prefer that (which might make sense especially since we seem to waiting on a lot of other PRs).
"extends": "../../../config/api-extractor.json", | ||
"mainEntryPointFilePath": "../dist/lite/firestore/lite/index.d.ts", | ||
"dtsRollup": { | ||
"enabled": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to do that, neither now nor in the future. Most of our types are incompatible with one another (i.e. a DocumentReference that contains a a Lite Firestore is incompatible with a DocumentReference for the main Firestore).
@@ -1,5 +1,5 @@ | |||
{ | |||
"name": "@firebase/firestore/lite", | |||
"name": "@firebase/firestore-lite", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is invalid even outside of this PR. I get this error from IntelliJ when I turn on JSON schema validation:
String violates the pattern: '^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$'
Inspection info: This inspection checks that JSON files conform to JSON Schemas assigned to them
The pattern seems to allow only one scoped package. Do we need to change it or should I spend some time trying to figure out how to work around this limitation without the name change?
dest: 'dist/lite/src' | ||
}, | ||
{ | ||
// Copy into generated source files to support API Extractor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The source tree that it uses are the .d.ts generated files in dist/lite/firestore/src, and by default the "proto" dir is missing. I assume that is because we provide d.ts files to begin with and so nothing gets generated.
FWIW, I changed this to only copy the d.ts file.
@@ -365,31 +365,6 @@ export function snapshotEqual<T>( | |||
right: DocumentSnapshot<T> | QuerySnapshot<T> | |||
): boolean; | |||
|
|||
export type FirestoreErrorCode = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Lite SDK doesn't use FirestoreError.
PR updated to undo the api-extractor upgrade. |
Abandoning. |
This adds API Extractor to firestore lite. Fingers crossed that we can get the generated and the automated types to match (via follow-up cleanup).