Skip to content

Firebase Performance and Installations #1735

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 6 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# Used for approving minor changes, large-scale refactorings, and emergency situations.
# (secret team to avoid review requests)
#
# - @Feiyang1
# - @hiranya911
# - @mikelehen
# - @Feiyang1
# - @hiranya911
# - @mikelehen
# - @bojeil-google
# - @depoll
# - @hsubox76
Expand All @@ -27,9 +27,9 @@
# Used for approving firestore changes.
# (secret team to avoid review requests)
#
# - @mikelehen
# - @schmidt-sebastian
# - @wilhuff
# - @mikelehen
# - @schmidt-sebastian
# - @wilhuff
# - @gsoltis
# - @var-const
# - @rsgowman
Expand Down Expand Up @@ -67,3 +67,11 @@ packages/testing @tonymeng @ryanpbrewster @firebase/jssdk-global-approvers

# RxFire Code
packages/rxfire @davideast @jamesdaniels @firebase/jssdk-global-approvers

# Installations
packages/installations @mmermerkaya @andirayo @firebase/jssdk-global-approvers
packages/installations-types @mmermerkaya @andirayo @firebase/jssdk-global-approvers

# Performance Code
packages/performance @alikn @zijianjoy @firebase/jssdk-global-approvers
packages/performance-types @alikn @zijianjoy @firebase/jssdk-global-approvers
6 changes: 3 additions & 3 deletions integration/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"private": true,
"scripts": {
"build": "gulp compile-tests",
"pretest:manual": "npm run build",
"pretest:debug": "npm run build",
"test": "echo 'Automated tests temporarily disabled, run `npm run test:manual` to execute these tests'",
"pretest:manual": "yarn build",
"pretest:debug": "yarn build",
"test": "echo 'Automated tests temporarily disabled, run `yarn test:manual` to execute these tests'",
"test:manual": "karma start --single-run",
"test:debug": "karma start --auto-watch --browsers Chrome"
},
Expand Down
20 changes: 0 additions & 20 deletions integration/shared/namespaceDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,6 @@
},
"deepExtend": {
"__type": "function"
},
"Promise": {
"__type": "function",
"resolve": {
"__type": "function"
},
"reject": {
"__type": "function"
},
"all": {
"__type": "function"
},
"prototype": {
"then": {
"__type": "function"
},
"catch": {
"__type": "function"
}
}
}
},
"auth": {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"firebase",
"functions",
"realtime",
"storage"
"storage",
"performance"
],
"scripts": {
"dev": "lerna run --parallel --scope @firebase/* --scope firebase --scope rxfire dev",
Expand All @@ -32,7 +33,7 @@
"test:saucelabs": "karma start config/karma.saucelabs.js --single-run",
"docgen:js": "node scripts/docgen/generate-docs.js --api js",
"docgen:node": "node scripts/docgen/generate-docs.js --api node",
"docgen": "npm run docgen:js; npm run docgen:node",
"docgen": "yarn docgen:js; yarn docgen:node",
"prettier": "prettier --config .prettierrc --write '**/*.{ts,js}'"
},
"repository": {
Expand Down
1 change: 1 addition & 0 deletions packages/app-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type FirebaseOptions = {
projectId?: string;
storageBucket?: string;
messagingSenderId?: string;
appId?: string;
[name: string]: any;
};

Expand Down
22 changes: 22 additions & 0 deletions packages/app/index.lite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { createFirebaseNamespaceLite } from './src/lite/firebaseNamespaceLite';

export const firebase = createFirebaseNamespaceLite();

export default firebase;
16 changes: 16 additions & 0 deletions packages/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ to false and "main" to true:
https://github.com/rollup/rollup-plugin-node-resolve
`);

// Firebase Lite detection
if (self && 'firebase' in self) {
console.warn(`
Warning: Firebase is already defined in the global scope. Please make sure
Firebase library is only loaded once.
`);

const sdkVersion = ((self as any).firebase as FirebaseNamespace).SDK_VERSION;
if (sdkVersion && sdkVersion.indexOf('LITE') >= 0) {
console.warn(`
Warning: You are trying to load Firebase while using Firebase Performance standalone script.
You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.
`);
}
}

export const firebase = createFirebaseNamespace();

export default firebase;
5 changes: 4 additions & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"browser": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"react-native": "dist/index.rn.cjs.js",
"esm2017": "dist/index.esm2017.js",
"lite": "dist/index.lite.js",
"lite-esm2017": "dist/index.lite.esm2017.js",
"files": [
"dist"
],
Expand All @@ -17,7 +20,7 @@
"test:browser": "karma start --single-run",
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
"test:node": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --opts ../../config/mocha.node.opts",
"prepare": "npm run build"
"prepare": "yarn build"
},
"license": "Apache-2.0",
"dependencies": {
Expand Down
86 changes: 74 additions & 12 deletions packages/app/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@
* limitations under the License.
*/

import typescript from 'rollup-plugin-typescript2';
import typescriptPlugin from 'rollup-plugin-typescript2';
import replace from 'rollup-plugin-replace';
import typescript from 'typescript';
import pkg from './package.json';

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

const plugins = [
typescript({
typescript: require('typescript')
const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);

/**
* ES5 Builds
*/
const es5BuildPlugins = [
typescriptPlugin({
typescript
}),
replace({
delimiters: ['${', '}'],
Expand All @@ -33,18 +41,14 @@ const plugins = [
})
];

const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);

export default [
const es5Builds = [
{
input: 'index.ts',
output: [
{ file: pkg.browser, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true }
],
plugins,
plugins: es5BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
},
{
Expand All @@ -54,7 +58,7 @@ export default [
format: 'cjs',
sourcemap: true
},
plugins,
plugins: es5BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
},
{
Expand All @@ -64,10 +68,68 @@ export default [
format: 'cjs',
sourcemap: true
},
plugins,
plugins: es5BuildPlugins,
external: id =>
[...deps, 'react-native'].some(
dep => id === dep || id.startsWith(`${dep}/`)
)
},
{
input: 'index.lite.ts',
output: {
file: pkg.lite,
format: 'es',
sourcemap: true
},
plugins: es5BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];

/**
* ES2017 Builds
*/
const es2017BuildPlugins = [
typescriptPlugin({
typescript,
tsconfigOverride: {
compilerOptions: {
target: 'es2017'
}
}
}),
replace({
delimiters: ['${', '}'],
values: {
JSCORE_VERSION: firebasePkg.version
}
})
];

const es2017Builds = [
/**
* Browser Builds
*/
{
input: 'index.ts',
output: {
file: pkg.esm2017,
format: 'es',
sourcemap: true
},
plugins: es2017BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
},
{
input: 'index.lite.ts',
output: {
file: pkg['lite-esm2017'],
format: 'es',
sourcemap: true
},
plugins: es2017BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];

export default [...es5Builds, ...es2017Builds];
18 changes: 18 additions & 0 deletions packages/app/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export const DEFAULT_ENTRY_NAME = '[DEFAULT]';
4 changes: 2 additions & 2 deletions packages/app/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const enum AppError {
INVALID_APP_ARGUMENT = 'invalid-app-argument'
}

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

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

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