Skip to content

Commit

Permalink
Fix nodejs builds (#5400)
Browse files Browse the repository at this point in the history
* remove named export from app-compat

* cjs build

* firestoer lite export

* changeset
  • Loading branch information
Feiyang1 authored Aug 30, 2021
1 parent 3a50e2f commit cd15df0
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .changeset/eleven-swans-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@firebase/analytics-compat': patch
'@firebase/app-check-compat': patch
'@firebase/app-compat': patch
'@firebase/functions-compat': patch
---

Fix cjs builds by removing the named export from app-compat
5 changes: 5 additions & 0 deletions .changeset/late-bobcats-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/firestore': patch
---

Make firestore/lite available in nodejs
2 changes: 1 addition & 1 deletion packages/analytics-compat/src/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import { expect, use } from 'chai';
import { AnalyticsService } from './service';
import { firebase, FirebaseApp } from '@firebase/app-compat';
import firebase, { FirebaseApp } from '@firebase/app-compat';
import * as analyticsExp from '@firebase/analytics';
import { stub, match, SinonStub } from 'sinon';
import * as sinonChai from 'sinon-chai';
Expand Down
8 changes: 4 additions & 4 deletions packages/app-check-compat/src/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import { expect, use } from 'chai';
import { AppCheckService } from './service';
import { firebase, FirebaseApp } from '@firebase/app-compat';
import firebase, { FirebaseApp } from '@firebase/app-compat';
import * as appCheckExp from '@firebase/app-check';
import { stub, match, SinonStub } from 'sinon';
import * as sinonChai from 'sinon-chai';
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('Firebase App Check > Service', () => {

it(
'activate("string") calls modular initializeAppCheck() with a ' +
'ReCaptchaV3Provider',
'ReCaptchaV3Provider',
() => {
const initializeAppCheckStub = stub(appCheckExp, 'initializeAppCheck');
service = new AppCheckService(app);
Expand All @@ -80,7 +80,7 @@ describe('Firebase App Check > Service', () => {

it(
'activate(CustomProvider) calls modular initializeAppCheck() with' +
' a CustomProvider',
' a CustomProvider',
() => {
const initializeAppCheckStub = stub(appCheckExp, 'initializeAppCheck');
service = new AppCheckService(app);
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('Firebase App Check > Service', () => {

it('onTokenChanged() throws if activate() has not been called', async () => {
service = createTestService(app);
expect(() => service.onTokenChanged(() => {})).to.throw(
expect(() => service.onTokenChanged(() => { })).to.throw(
AppCheckError.USE_BEFORE_ACTIVATION
);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/app-compat/src/index.lite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { createFirebaseNamespaceLite } from './lite/firebaseNamespaceLite';
import { registerCoreComponents } from './registerCoreComponents';

export const firebase = createFirebaseNamespaceLite();
const firebase = createFirebaseNamespaceLite();

registerCoreComponents('lite');

Expand Down
2 changes: 1 addition & 1 deletion packages/app-compat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (isBrowser() && (self as any).firebase !== undefined) {
}
}

export const firebase = firebaseNamespace;
const firebase = firebaseNamespace;

registerCoreComponents();

Expand Down
10 changes: 10 additions & 0 deletions packages/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@
"test:prepare": "node ./scripts/prepare-test.js",
"typings:public": "node ../../scripts/exp/use_typings.js ./dist/index.d.ts"
},
"exports": {
".": {
"node": "./dist/index.node.cjs.js",
"default": "./dist/index.esm2017.js"
},
"./lite": {
"node": "./dist/lite/index.node.cjs.js",
"default": "./dist/lite/index.browser.esm2017.js"
}
},
"main": "dist/index.node.cjs.js",
"main-esm": "dist/index.node.cjs.esm2017.js",
"react-native": "dist/index.rn.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/functions-compat/src/callable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { expect } from 'chai';
import { FunctionsErrorCode } from '@firebase/functions';
import { createTestService } from '../test/utils';
import { firebase, FirebaseApp } from '@firebase/app-compat';
import firebase, { FirebaseApp } from '@firebase/app-compat';

// eslint-disable-next-line @typescript-eslint/no-require-imports
export const TEST_PROJECT = require('../../../config/project.json');
Expand Down
2 changes: 1 addition & 1 deletion packages/functions-compat/src/index.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { firebase } from '@firebase/app-compat';
import firebase from '@firebase/app-compat';
import { name, version } from '../package.json';
import { registerFunctions } from './register';

Expand Down
2 changes: 1 addition & 1 deletion packages/functions-compat/src/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { expect, use } from 'chai';
import { createTestService } from '../test/utils';
import { FunctionsService } from './service';
import { firebase, FirebaseApp } from '@firebase/app-compat';
import firebase, { FirebaseApp } from '@firebase/app-compat';
import * as functionsExp from '@firebase/functions';
import { stub, match, SinonStub } from 'sinon';
import * as sinonChai from 'sinon-chai';
Expand Down

0 comments on commit cd15df0

Please sign in to comment.