Skip to content

Commit e1ab520

Browse files
committed
Merge branch 'master' of https://github.com/firebase/firebase-js-sdk into ch-strict
2 parents 54bdc4e + 3635f53 commit e1ab520

Some content is hidden

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

49 files changed

+413
-267
lines changed

.travis.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,15 @@ matrix:
4242
jobs:
4343
allow_failures:
4444
- script: yarn test:saucelabs
45-
- script: yarn test:saucelabs --database-firestore-only
4645
include:
4746
- name: Node.js and Browser (Chrome) Test
4847
stage: test
4948
script: xvfb-run yarn test
5049
after_success: yarn test:coverage
51-
- name: Cross Browser Test for SDKs except Database and Firestore
50+
- name: Cross Browser Test for SDKs
5251
stage: test
5352
script: yarn test:saucelabs
5453
if: type = push
55-
- name: Cross Browser Test for Database and Firestore SDK
56-
stage: test
57-
script: yarn test:saucelabs --database-firestore-only
58-
if: type = push
5954
- stage: deploy
6055
script: skip
6156
# NPM Canary Build Config

ENVIRONMENTS.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ To get started using Firebase, see
1818

1919
[![Release Notes](https://img.shields.io/npm/v/firebase.svg?style=flat-square&label=Release%20Notes%20for&labelColor=039be5&color=666)](https://firebase.google.com/support/release-notes/js)
2020

21+
## Supported Environments
22+
Please see [Environment Support](https://firebase.google.com/support/guides/environments_js-sdk).
23+
2124
## SDK Dev Workflow
2225

2326
### Prerequisites

config/karma.saucelabs.js

Lines changed: 98 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,98 @@
1616
*/
1717

1818
const argv = require('yargs').argv;
19-
const glob = require('glob');
20-
const karma = require('karma');
2119
const path = require('path');
2220
const karmaBase = require('./karma.base');
2321

22+
// karma.conf.js test configuration file to run.
23+
const testConfigFile = argv['testConfigFile'];
24+
if (!testConfigFile) {
25+
console.error('No test file path provided.');
26+
process.exit(1);
27+
}
28+
29+
/**
30+
* Custom SauceLabs Launchers
31+
*/
32+
const browserMap = {
33+
// Desktop
34+
Chrome_Windows: seleniumLauncher('chrome', 'Windows 10', 'latest'),
35+
Firefox_Windows: seleniumLauncher('firefox', 'Windows 10', 'latest'),
36+
Safari_macOS: seleniumLauncher('safari', 'macOS 10.13', 'latest'),
37+
Edge_Windows: seleniumLauncher('MicrosoftEdge', 'Windows 10', 'latest'),
38+
IE_Windows: seleniumLauncher('internet explorer', 'Windows 10', 'latest')
39+
40+
// Mobile
41+
// Safari_iOS: appiumLauncher('Safari', 'iPhone Simulator', 'iOS', '11.2'),
42+
// Chrome_Android: appiumLauncher('Chrome', 'Android Emulator', 'Android', '6.0')
43+
};
44+
45+
/**
46+
* Any special options per package.
47+
*/
48+
const packageConfigs = {
49+
messaging: {
50+
// Messaging currently only supports these browsers.
51+
browsers: ['Chrome_Windows', 'Firefox_Windows', 'Edge_Windows']
52+
}
53+
};
54+
55+
/**
56+
* Gets the browser/launcher map for this package.
57+
*
58+
* @param {string} packageName Name of package being tested (e.g., "firestore")
59+
*/
60+
function getSauceLabsBrowsers(packageName) {
61+
if (packageConfigs[packageName]) {
62+
const filteredBrowserMap = {};
63+
for (const browserKey in browserMap) {
64+
if (packageConfigs[packageName].browsers.includes(browserKey)) {
65+
filteredBrowserMap[browserKey] = browserMap[browserKey];
66+
}
67+
}
68+
return filteredBrowserMap;
69+
} else {
70+
return browserMap;
71+
}
72+
}
73+
74+
/**
75+
* Get package name from package path command line arg.
76+
*/
77+
function getPackageLabels() {
78+
const match = testConfigFile.match(
79+
/([a-zA-Z]+)\/([a-zA-Z]+)\/karma\.conf\.js/
80+
);
81+
return {
82+
type: match[1],
83+
name: match[2]
84+
};
85+
}
86+
2487
/**
2588
* Gets a list of file patterns for test, defined individually
2689
* in karma.conf.js in each package under worksapce packages or
2790
* integration.
2891
*/
2992
function getTestFiles() {
3093
let root = path.resolve(__dirname, '..');
31-
configs = argv['database-firestore-only']
32-
? glob.sync('packages/{database,firestore}/karma.conf.js')
33-
: glob.sync('{packages,integration}/*/karma.conf.js', {
34-
// Excluded due to flakiness or long run time.
35-
ignore: [
36-
'packages/database/*',
37-
'packages/firestore/*',
38-
'integration/firestore/*',
39-
'integration/messaging/*'
40-
]
41-
});
42-
files = configs.map(x => {
43-
let patterns = require(path.join(root, x)).files;
44-
let dirname = path.dirname(x);
45-
return patterns.map(p => path.join(dirname, p));
46-
});
47-
return [].concat(...files);
94+
const { name: packageName } = getPackageLabels();
95+
let patterns = require(path.join(root, testConfigFile)).files;
96+
let dirname = path.dirname(testConfigFile);
97+
return { packageName, files: patterns.map(p => path.join(dirname, p)) };
4898
}
4999

50100
function seleniumLauncher(browserName, platform, version) {
101+
const { name, type } = getPackageLabels();
102+
const testName =
103+
type === 'integration'
104+
? `${type}-${name}-${browserName}`
105+
: `${name}-${browserName}`;
51106
return {
52107
base: 'SauceLabs',
53108
browserName: browserName,
54109
extendedDebugging: 'true',
110+
name: testName,
55111
recordLogs: 'true',
56112
recordVideo: 'true',
57113
recordScreenshots: 'true',
@@ -81,27 +137,32 @@ function appiumLauncher(
81137
};
82138
}
83139

84-
/**
85-
* Custom SauceLabs Launchers
86-
*/
87-
const sauceLabsBrowsers = {
88-
// Desktop
89-
Chrome_Windows: seleniumLauncher('chrome', 'Windows 10', 'latest'),
90-
Firefox_Windows: seleniumLauncher('firefox', 'Windows 10', 'latest'),
91-
Safari_macOS: seleniumLauncher('safari', 'macOS 10.13', 'latest'),
92-
Edge_Windows: seleniumLauncher('MicrosoftEdge', 'Windows 10', 'latest'),
93-
IE_Windows: seleniumLauncher('internet explorer', 'Windows 10', 'latest')
94-
95-
// Mobile
96-
// Safari_iOS: appiumLauncher('Safari', 'iPhone Simulator', 'iOS', '11.2'),
97-
// Chrome_Android: appiumLauncher('Chrome', 'Android Emulator', 'Android', '6.0')
98-
};
99-
100140
module.exports = function(config) {
141+
const { packageName, files: testFiles } = getTestFiles();
142+
const sauceLabsBrowsers = getSauceLabsBrowsers(packageName);
143+
144+
const sauceLabsConfig = {
145+
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER + '-' + packageName,
146+
build: process.env.TRAVIS_BUILD_NUMBER || argv['buildNumber'],
147+
username: process.env.SAUCE_USERNAME,
148+
accessKey: process.env.SAUCE_ACCESS_KEY,
149+
startConnect: true,
150+
connectOptions: {
151+
// Realtime Database uses WebSockets to connect to firebaseio.com
152+
// so we have to set noSslBumpDomains. Theoretically SSL Bumping
153+
// only needs to be disabled for 'firebaseio.com'. However, we are
154+
// seeing much longer test time with that configuration, so leave
155+
// it as 'all' for now.
156+
// See https://wiki.saucelabs.com/display/DOCS/Troubleshooting+Sauce+Connect
157+
// for more details.
158+
noSslBumpDomains: 'all'
159+
}
160+
};
161+
101162
const karmaConfig = Object.assign({}, karmaBase, {
102163
basePath: '../',
103164

104-
files: ['packages/polyfill/index.ts', ...getTestFiles()],
165+
files: ['packages/polyfill/index.ts', ...testFiles],
105166

106167
logLevel: config.LOG_INFO,
107168

@@ -151,22 +212,7 @@ module.exports = function(config) {
151212
overviewColumn: false
152213
},
153214

154-
sauceLabs: {
155-
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
156-
username: process.env.SAUCE_USERNAME,
157-
accessKey: process.env.SAUCE_ACCESS_KEY,
158-
startConnect: true,
159-
connectOptions: {
160-
// Realtime Database uses WebSockets to connect to firebaseio.com
161-
// so we have to set noSslBumpDomains. Theoretically SSL Bumping
162-
// only needs to be disabled for 'firebaseio.com'. However, we are
163-
// seeing much longer test time with that configuration, so leave
164-
// it as 'all' for now.
165-
// See https://wiki.saucelabs.com/display/DOCS/Troubleshooting+Sauce+Connect
166-
// for more details.
167-
noSslBumpDomains: 'all'
168-
}
169-
}
215+
sauceLabs: sauceLabsConfig
170216
});
171217

172218
config.set(karmaConfig);

config/webpack.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ module.exports = {
3030
loader: 'ts-loader',
3131
options: {
3232
compilerOptions: {
33-
module: 'commonjs'
33+
module: 'commonjs',
34+
downlevelIteration: true
3435
}
3536
}
3637
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"pretest:coverage": "mkdirp coverage",
3030
"test:coverage": "lcov-result-merger 'packages/**/lcov.info' | coveralls",
3131
"test:setup": "node tools/config.js",
32-
"pretest:saucelabs": "lerna run --parallel pretest",
33-
"test:saucelabs": "karma start config/karma.saucelabs.js --single-run",
32+
"test:saucelabs": "node scripts/run_saucelabs.js",
33+
"test:saucelabs:single": "karma start config/karma.saucelabs.js --single-run",
3434
"docgen:js": "node scripts/docgen/generate-docs.js --api js",
3535
"docgen:node": "node scripts/docgen/generate-docs.js --api node",
3636
"docgen": "yarn docgen:js; yarn docgen:node",

packages/app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"rollup": "1.11.0",
5353
"rollup-plugin-replace": "2.2.0",
5454
"rollup-plugin-typescript2": "0.21.0",
55+
"rollup-plugin-json": "4.0.0",
5556
"sinon": "7.3.2",
5657
"source-map-loader": "0.2.4",
5758
"ts-loader": "5.4.5",
@@ -67,7 +68,7 @@
6768
"bugs": {
6869
"url": "https://github.com/firebase/firebase-js-sdk/issues"
6970
},
70-
"typings": "dist/index.d.ts",
71+
"typings": "dist/app/index.d.ts",
7172
"nyc": {
7273
"extension": [
7374
".ts"

packages/app/rollup.config.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
*/
1717

1818
import typescriptPlugin from 'rollup-plugin-typescript2';
19-
import replace from 'rollup-plugin-replace';
19+
import json from 'rollup-plugin-json';
2020
import typescript from 'typescript';
2121
import pkg from './package.json';
2222

23-
import firebasePkg from '../firebase/package.json';
24-
2523
const deps = Object.keys(
2624
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
2725
);
@@ -33,12 +31,7 @@ const es5BuildPlugins = [
3331
typescriptPlugin({
3432
typescript
3533
}),
36-
replace({
37-
delimiters: ['${', '}'],
38-
values: {
39-
JSCORE_VERSION: firebasePkg.version
40-
}
41-
})
34+
json()
4235
];
4336

4437
const es5Builds = [
@@ -98,11 +91,8 @@ const es2017BuildPlugins = [
9891
}
9992
}
10093
}),
101-
replace({
102-
delimiters: ['${', '}'],
103-
values: {
104-
JSCORE_VERSION: firebasePkg.version
105-
}
94+
json({
95+
preferConst: true
10696
})
10797
];
10898

packages/app/src/firebaseNamespaceCore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { FirebaseAppImpl } from './firebaseApp';
3434
import { error, AppError } from './errors';
3535
import { FirebaseAppLiteImpl } from './lite/firebaseAppLite';
3636
import { DEFAULT_ENTRY_NAME } from './constants';
37+
import { version } from '../../firebase/package.json';
3738

3839
function contains(obj: object, key: string) {
3940
return Object.prototype.hasOwnProperty.call(obj, key);
@@ -62,7 +63,7 @@ export function createFirebaseNamespaceCore(
6263
initializeApp: initializeApp,
6364
app: app as any,
6465
apps: null as any,
65-
SDK_VERSION: '${JSCORE_VERSION}',
66+
SDK_VERSION: version,
6667
INTERNAL: {
6768
registerService,
6869
removeApp,

packages/app/src/lite/firebaseNamespaceLite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { createFirebaseNamespaceCore } from '../firebaseNamespaceCore';
2828
export function createFirebaseNamespaceLite(): FirebaseNamespace {
2929
const namespace = createFirebaseNamespaceCore(FirebaseAppLiteImpl);
3030

31-
namespace.SDK_VERSION = '${JSCORE_VERSION}_LITE';
31+
namespace.SDK_VERSION = `${namespace.SDK_VERSION}_LITE`;
3232

3333
const registerService = (namespace as _FirebaseNamespace).INTERNAL
3434
.registerService;

packages/app/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "../../config/tsconfig.base.json",
33
"compilerOptions": {
4-
"outDir": "dist"
4+
"outDir": "dist",
5+
"resolveJsonModule": true
56
},
67
"exclude": [
78
"dist/**/*"

packages/firebase/rollup.config.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,6 @@ import { terser } from 'rollup-plugin-terser';
2626
import pkg from './package.json';
2727

2828
import appPkg from './app/package.json';
29-
import authPkg from './auth/package.json';
30-
import databasePkg from './database/package.json';
31-
import firestorePkg from './firestore/package.json';
32-
import functionsPkg from './functions/package.json';
33-
import messagingPkg from './messaging/package.json';
34-
import storagePkg from './storage/package.json';
35-
import performancePkg from './performance/package.json';
36-
37-
const pkgsByName = {
38-
app: appPkg,
39-
auth: authPkg,
40-
database: databasePkg,
41-
firestore: firestorePkg,
42-
functions: functionsPkg,
43-
messaging: messagingPkg,
44-
storage: storagePkg,
45-
performance: performancePkg
46-
};
4729

4830
const plugins = [
4931
sourcemaps(),

0 commit comments

Comments
 (0)