Skip to content

Commit 932d7be

Browse files
authored
Firebase Performance and Installations (#1735)
* Firebase Performance * Remove outdated test case * Increase timeout for test case that fails in CI * Fix flaky test * Fix messaging tests * null check before checking SDKVERSION
1 parent b6a05fd commit 932d7be

File tree

140 files changed

+9225
-855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+9225
-855
lines changed

.github/CODEOWNERS

+14-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
# Used for approving minor changes, large-scale refactorings, and emergency situations.
1414
# (secret team to avoid review requests)
1515
#
16-
# - @Feiyang1
17-
# - @hiranya911
18-
# - @mikelehen
16+
# - @Feiyang1
17+
# - @hiranya911
18+
# - @mikelehen
1919
# - @bojeil-google
2020
# - @depoll
2121
# - @hsubox76
@@ -27,9 +27,9 @@
2727
# Used for approving firestore changes.
2828
# (secret team to avoid review requests)
2929
#
30-
# - @mikelehen
31-
# - @schmidt-sebastian
32-
# - @wilhuff
30+
# - @mikelehen
31+
# - @schmidt-sebastian
32+
# - @wilhuff
3333
# - @gsoltis
3434
# - @var-const
3535
# - @rsgowman
@@ -67,3 +67,11 @@ packages/testing @tonymeng @ryanpbrewster @firebase/jssdk-global-approvers
6767

6868
# RxFire Code
6969
packages/rxfire @davideast @jamesdaniels @firebase/jssdk-global-approvers
70+
71+
# Installations
72+
packages/installations @mmermerkaya @andirayo @firebase/jssdk-global-approvers
73+
packages/installations-types @mmermerkaya @andirayo @firebase/jssdk-global-approvers
74+
75+
# Performance Code
76+
packages/performance @alikn @zijianjoy @firebase/jssdk-global-approvers
77+
packages/performance-types @alikn @zijianjoy @firebase/jssdk-global-approvers

integration/firestore/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"private": true,
55
"scripts": {
66
"build": "gulp compile-tests",
7-
"pretest:manual": "npm run build",
8-
"pretest:debug": "npm run build",
9-
"test": "echo 'Automated tests temporarily disabled, run `npm run test:manual` to execute these tests'",
7+
"pretest:manual": "yarn build",
8+
"pretest:debug": "yarn build",
9+
"test": "echo 'Automated tests temporarily disabled, run `yarn test:manual` to execute these tests'",
1010
"test:manual": "karma start --single-run",
1111
"test:debug": "karma start --auto-watch --browsers Chrome"
1212
},

integration/shared/namespaceDefinition.json

-20
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,6 @@
9595
},
9696
"deepExtend": {
9797
"__type": "function"
98-
},
99-
"Promise": {
100-
"__type": "function",
101-
"resolve": {
102-
"__type": "function"
103-
},
104-
"reject": {
105-
"__type": "function"
106-
},
107-
"all": {
108-
"__type": "function"
109-
},
110-
"prototype": {
111-
"then": {
112-
"__type": "function"
113-
},
114-
"catch": {
115-
"__type": "function"
116-
}
117-
}
11898
}
11999
},
120100
"auth": {

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"firebase",
1414
"functions",
1515
"realtime",
16-
"storage"
16+
"storage",
17+
"performance"
1718
],
1819
"scripts": {
1920
"dev": "lerna run --parallel --scope @firebase/* --scope firebase --scope rxfire dev",
@@ -32,7 +33,7 @@
3233
"test:saucelabs": "karma start config/karma.saucelabs.js --single-run",
3334
"docgen:js": "node scripts/docgen/generate-docs.js --api js",
3435
"docgen:node": "node scripts/docgen/generate-docs.js --api node",
35-
"docgen": "npm run docgen:js; npm run docgen:node",
36+
"docgen": "yarn docgen:js; yarn docgen:node",
3637
"prettier": "prettier --config .prettierrc --write '**/*.{ts,js}'"
3738
},
3839
"repository": {

packages/app-types/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type FirebaseOptions = {
2222
projectId?: string;
2323
storageBucket?: string;
2424
messagingSenderId?: string;
25+
appId?: string;
2526
[name: string]: any;
2627
};
2728

packages/app/index.lite.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @license
3+
* Copyright 2019 Google Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { createFirebaseNamespaceLite } from './src/lite/firebaseNamespaceLite';
19+
20+
export const firebase = createFirebaseNamespaceLite();
21+
22+
export default firebase;

packages/app/index.ts

+16
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ to false and "main" to true:
4040
https://github.com/rollup/rollup-plugin-node-resolve
4141
`);
4242

43+
// Firebase Lite detection
44+
if (self && 'firebase' in self) {
45+
console.warn(`
46+
Warning: Firebase is already defined in the global scope. Please make sure
47+
Firebase library is only loaded once.
48+
`);
49+
50+
const sdkVersion = ((self as any).firebase as FirebaseNamespace).SDK_VERSION;
51+
if (sdkVersion && sdkVersion.indexOf('LITE') >= 0) {
52+
console.warn(`
53+
Warning: You are trying to load Firebase while using Firebase Performance standalone script.
54+
You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.
55+
`);
56+
}
57+
}
58+
4359
export const firebase = createFirebaseNamespace();
4460

4561
export default firebase;

packages/app/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"browser": "dist/index.cjs.js",
88
"module": "dist/index.esm.js",
99
"react-native": "dist/index.rn.cjs.js",
10+
"esm2017": "dist/index.esm2017.js",
11+
"lite": "dist/index.lite.js",
12+
"lite-esm2017": "dist/index.lite.esm2017.js",
1013
"files": [
1114
"dist"
1215
],
@@ -17,7 +20,7 @@
1720
"test:browser": "karma start --single-run",
1821
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
1922
"test:node": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --opts ../../config/mocha.node.opts",
20-
"prepare": "npm run build"
23+
"prepare": "yarn build"
2124
},
2225
"license": "Apache-2.0",
2326
"dependencies": {

packages/app/rollup.config.js

+74-12
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,23 @@
1515
* limitations under the License.
1616
*/
1717

18-
import typescript from 'rollup-plugin-typescript2';
18+
import typescriptPlugin from 'rollup-plugin-typescript2';
1919
import replace from 'rollup-plugin-replace';
20+
import typescript from 'typescript';
2021
import pkg from './package.json';
2122

2223
import firebasePkg from '../firebase/package.json';
2324

24-
const plugins = [
25-
typescript({
26-
typescript: require('typescript')
25+
const deps = Object.keys(
26+
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
27+
);
28+
29+
/**
30+
* ES5 Builds
31+
*/
32+
const es5BuildPlugins = [
33+
typescriptPlugin({
34+
typescript
2735
}),
2836
replace({
2937
delimiters: ['${', '}'],
@@ -33,18 +41,14 @@ const plugins = [
3341
})
3442
];
3543

36-
const deps = Object.keys(
37-
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
38-
);
39-
40-
export default [
44+
const es5Builds = [
4145
{
4246
input: 'index.ts',
4347
output: [
4448
{ file: pkg.browser, format: 'cjs', sourcemap: true },
4549
{ file: pkg.module, format: 'es', sourcemap: true }
4650
],
47-
plugins,
51+
plugins: es5BuildPlugins,
4852
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
4953
},
5054
{
@@ -54,7 +58,7 @@ export default [
5458
format: 'cjs',
5559
sourcemap: true
5660
},
57-
plugins,
61+
plugins: es5BuildPlugins,
5862
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
5963
},
6064
{
@@ -64,10 +68,68 @@ export default [
6468
format: 'cjs',
6569
sourcemap: true
6670
},
67-
plugins,
71+
plugins: es5BuildPlugins,
6872
external: id =>
6973
[...deps, 'react-native'].some(
7074
dep => id === dep || id.startsWith(`${dep}/`)
7175
)
76+
},
77+
{
78+
input: 'index.lite.ts',
79+
output: {
80+
file: pkg.lite,
81+
format: 'es',
82+
sourcemap: true
83+
},
84+
plugins: es5BuildPlugins,
85+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
86+
}
87+
];
88+
89+
/**
90+
* ES2017 Builds
91+
*/
92+
const es2017BuildPlugins = [
93+
typescriptPlugin({
94+
typescript,
95+
tsconfigOverride: {
96+
compilerOptions: {
97+
target: 'es2017'
98+
}
99+
}
100+
}),
101+
replace({
102+
delimiters: ['${', '}'],
103+
values: {
104+
JSCORE_VERSION: firebasePkg.version
105+
}
106+
})
107+
];
108+
109+
const es2017Builds = [
110+
/**
111+
* Browser Builds
112+
*/
113+
{
114+
input: 'index.ts',
115+
output: {
116+
file: pkg.esm2017,
117+
format: 'es',
118+
sourcemap: true
119+
},
120+
plugins: es2017BuildPlugins,
121+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
122+
},
123+
{
124+
input: 'index.lite.ts',
125+
output: {
126+
file: pkg['lite-esm2017'],
127+
format: 'es',
128+
sourcemap: true
129+
},
130+
plugins: es2017BuildPlugins,
131+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
72132
}
73133
];
134+
135+
export default [...es5Builds, ...es2017Builds];

packages/app/src/constants.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright 2019 Google Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
export const DEFAULT_ENTRY_NAME = '[DEFAULT]';

packages/app/src/errors.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const enum AppError {
2626
INVALID_APP_ARGUMENT = 'invalid-app-argument'
2727
}
2828

29-
const errors: ErrorMap<AppError> = {
29+
const ERRORS: ErrorMap<AppError> = {
3030
[AppError.NO_APP]:
3131
"No Firebase App '{$name}' has been created - " +
3232
'call Firebase App.initializeApp()',
@@ -40,7 +40,7 @@ const errors: ErrorMap<AppError> = {
4040
'Firebase App instance.'
4141
};
4242

43-
const appErrors = new ErrorFactory('app', 'Firebase', errors);
43+
const appErrors = new ErrorFactory<AppError>('app', 'Firebase', ERRORS);
4444

4545
export function error(code: AppError, args?: { [name: string]: any }) {
4646
throw appErrors.create(code, args);

0 commit comments

Comments
 (0)