Skip to content

Commit 69fe8a6

Browse files
Merge branch 'master' into mrschmidt/removegenerators
2 parents 5797b97 + 7b17e03 commit 69fe8a6

File tree

13 files changed

+320
-250
lines changed

13 files changed

+320
-250
lines changed

.github/workflows/cross-browser-test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ jobs:
99
cross-browser-test:
1010
name: Cross-Browser (Saucelabs) Tests
1111
runs-on: ubuntu-latest
12-
if: github.event.pull_request.merged
1312
env:
1413
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
1514
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}

config/karma.saucelabs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -201,7 +201,7 @@ module.exports = function(config) {
201201
maxLogLines: 5,
202202
suppressErrorSummary: false,
203203
suppressFailed: false,
204-
suppressPassed: true,
204+
suppressPassed: false,
205205
suppressSkipped: true,
206206
showSpecTiming: true,
207207
failFast: false

packages/analytics/index.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2019 Google Inc.
3+
* Copyright 2019 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -88,7 +88,9 @@ describe('FirebaseAnalytics instance tests', () => {
8888
currency: 'USD'
8989
});
9090
// Clear event stack of async FID call.
91-
await fidDeferred.promise;
91+
// For IE: Need then() or else "expect" runs immediately on FID resolve
92+
// before the other statements in initializeGAId.
93+
await fidDeferred.promise.then();
9294
expect(gtagStub).to.have.been.calledWith('js');
9395
expect(gtagStub).to.have.been.calledWith(
9496
GtagCommand.CONFIG,
@@ -158,7 +160,9 @@ describe('FirebaseAnalytics instance tests', () => {
158160
currency: 'USD'
159161
});
160162
// Clear event stack of async FID call.
161-
await fidDeferred.promise;
163+
// For IE: Need then() or else "expect" runs immediately on FID resolve
164+
// before the other statements in initializeGAId.
165+
await fidDeferred.promise.then();
162166
expect(gtagStub).to.have.been.calledWith('js');
163167
expect(gtagStub).to.have.been.calledWith(
164168
GtagCommand.CONFIG,
@@ -195,8 +199,12 @@ describe('FirebaseAnalytics instance tests', () => {
195199
delete window['dataLayer'];
196200
removeGtagScript();
197201
});
198-
it('Adds the script tag to the page', () => {
202+
it('Adds the script tag to the page', async () => {
203+
const { initializedIdPromisesMap } = getGlobalVars();
204+
await initializedIdPromisesMap[analyticsId];
199205
expect(findGtagScriptOnPage()).to.not.be.null;
206+
expect(typeof window['gtag']).to.equal('function');
207+
expect(Array.isArray(window['dataLayer'])).to.be.true;
200208
});
201209
});
202210
});

packages/firebase/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,8 @@ declare namespace firebase {
11171117
* // https://console.firebase.google.com
11181118
* firebase.initializeApp({
11191119
* apiKey: "AIza....", // Auth / General Use
1120+
* applicationId: "1:27992087142:web:ce....", // General Use
1121+
* projectId: "my-firebase-project", // General Use
11201122
* authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
11211123
* databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
11221124
* storageBucket: "YOUR_APP.appspot.com", // Storage
@@ -1129,9 +1131,12 @@ declare namespace firebase {
11291131
*
11301132
* // Initialize another app
11311133
* var otherApp = firebase.initializeApp({
1134+
* apiKey: "AIza....",
1135+
* applicationId: "1:27992087142:web:ce....",
1136+
* projectId: "my-firebase-project",
11321137
* databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
11331138
* storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com"
1134-
* }, "otherApp");
1139+
* }, "nameOfOtherApp");
11351140
* ```
11361141
*
11371142
* @param options Options to configure the app's services.

packages/firestore/memory/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@firebase/firestore/memory",
33
"description": "A memory-only build of the Cloud Firestore JS SDK.",
44
"main": "../dist/index.memory.node.cjs.js",
5+
"main-esm2017": "../dist/index.memory.node.esm2017.js",
56
"browser": "../dist/index.memory.cjs.js",
67
"module": "../dist/index.memory.esm.js",
78
"esm2017": "../dist/index.memory.esm2017.js",

packages/firestore/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"scripts": {
77
"prebuild": "tsc -d --downlevelIteration --declarationDir dist/lib --emitDeclarationOnly && tsc -m es2015 --moduleResolution node scripts/*.ts ",
8-
"build": "rollup -c",
8+
"build": "rollup -c rollup.config.es2017.js && rollup -c rollup.config.es5.js",
99
"build:deps": "lerna run --scope @firebase/'{app,firestore}' --include-dependencies build",
1010
"build:console": "node tools/console.build.js",
1111
"predev": "yarn prebuild",
@@ -26,6 +26,7 @@
2626
"prepare": "yarn build"
2727
},
2828
"main": "dist/index.node.cjs.js",
29+
"main-esm2017": "dist/index.node.esm2017.js",
2930
"browser": "dist/index.cjs.js",
3031
"module": "dist/index.esm.js",
3132
"esm2017": "dist/index.esm2017.js",
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/**
2+
* @license
3+
* Copyright 2018 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 * as path from 'path';
19+
20+
import json from 'rollup-plugin-json';
21+
import typescriptPlugin from 'rollup-plugin-typescript2';
22+
import replace from 'rollup-plugin-replace';
23+
import copy from 'rollup-plugin-copy-assets';
24+
import typescript from 'typescript';
25+
import { terser } from 'rollup-plugin-terser';
26+
27+
import pkg from './package.json';
28+
import memoryPkg from './memory/package.json';
29+
30+
import {
31+
appendPrivatePrefixTransformers,
32+
manglePrivatePropertiesOptions,
33+
resolveNodeExterns,
34+
resolveBrowserExterns
35+
} from './rollup.shared';
36+
37+
// Firestore is released in a number of different build configurations:
38+
// - Browser builds that support persistence in ES5 CJS and ES5 ESM formats and
39+
// ES2017 in ESM format.
40+
// - In-memory Browser builds that support persistence in ES5 CJS and ES5 ESM
41+
// formats and ES2017 in ESM format.
42+
// - A NodeJS build that supports persistence (to be used with an IndexedDb
43+
// shim)
44+
// - A in-memory only NodeJS build
45+
//
46+
// The in-memory builds are roughly 130 KB smaller, but throw an exception
47+
// for calls to `enablePersistence()` or `clearPersistence()`.
48+
//
49+
// We use two different rollup pipelines to take advantage of tree shaking,
50+
// as Rollup does not support tree shaking for Typescript classes transpiled
51+
// down to ES5 (see https://bit.ly/340P23U). The build pipeline in this file
52+
// produces tree-shaken ES2017 builds that are consumed by the ES5 builds in
53+
// `rollup.config.es.js`.
54+
//
55+
// All browser builds rely on Terser's property name mangling to reduce code
56+
// size.
57+
//
58+
// See https://g3doc/firebase/jscore/g3doc/contributing/builds.md
59+
// for a description of the various JavaScript formats used in our SDKs.
60+
61+
// MARK: Browser builds
62+
63+
const browserBuildPlugins = [
64+
typescriptPlugin({
65+
typescript,
66+
tsconfigOverride: {
67+
compilerOptions: {
68+
target: 'es2017'
69+
}
70+
},
71+
clean: true,
72+
transformers: appendPrivatePrefixTransformers
73+
}),
74+
json({ preferConst: true }),
75+
terser(manglePrivatePropertiesOptions)
76+
];
77+
78+
const browserBuilds = [
79+
// Persistence build
80+
{
81+
input: 'index.ts',
82+
output: {
83+
file: pkg.esm2017,
84+
format: 'es',
85+
sourcemap: true
86+
},
87+
plugins: browserBuildPlugins,
88+
external: resolveBrowserExterns
89+
},
90+
// Memory-only build
91+
{
92+
input: 'index.memory.ts',
93+
output: {
94+
file: path.resolve('./memory', memoryPkg.esm2017),
95+
format: 'es',
96+
sourcemap: true
97+
},
98+
plugins: browserBuildPlugins,
99+
external: resolveBrowserExterns
100+
}
101+
];
102+
103+
// MARK: Node builds
104+
105+
const nodeBuildPlugins = [
106+
typescriptPlugin({
107+
typescript,
108+
tsconfigOverride: {
109+
compilerOptions: {
110+
target: 'es2017'
111+
}
112+
},
113+
clean: true
114+
}),
115+
json(),
116+
// Needed as we also use the *.proto files
117+
copy({
118+
assets: ['./src/protos']
119+
}),
120+
replace({
121+
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('src/protos')
122+
})
123+
];
124+
125+
const nodeBuilds = [
126+
// Persistence build
127+
{
128+
input: 'index.node.ts',
129+
output: [{ file: pkg['main-esm2017'], format: 'es', sourcemap: true }],
130+
plugins: nodeBuildPlugins,
131+
external: resolveNodeExterns
132+
},
133+
// Memory-only build
134+
{
135+
input: 'index.node.memory.ts',
136+
output: [
137+
{
138+
file: path.resolve('./memory', memoryPkg['main-esm2017']),
139+
format: 'es',
140+
sourcemap: true
141+
}
142+
],
143+
plugins: nodeBuildPlugins,
144+
external: resolveNodeExterns
145+
}
146+
];
147+
148+
export default [...browserBuilds, ...nodeBuilds];
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/**
2+
* @license
3+
* Copyright 2018 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 * as path from 'path';
19+
20+
import typescriptPlugin from 'rollup-plugin-typescript2';
21+
import sourcemaps from 'rollup-plugin-sourcemaps';
22+
import typescript from 'typescript';
23+
import { terser } from 'rollup-plugin-terser';
24+
import { resolveNodeExterns, resolveBrowserExterns } from './rollup.shared';
25+
26+
import pkg from './package.json';
27+
import memoryPkg from './memory/package.json';
28+
29+
// This file defines the second rollup pipeline and transpiles the ES2017 SDK
30+
// into ES5 code. By splitting the build process into two independent build
31+
// pipelines, we take advantage of tree shaking in ES2017 builds even for
32+
// language levels that don't support tree shaking.
33+
34+
const browserPlugins = [
35+
typescriptPlugin({
36+
typescript,
37+
compilerOptions: {
38+
allowJs: true
39+
},
40+
include: ['dist/*.js']
41+
}),
42+
terser({
43+
output: {
44+
comments: 'all',
45+
beautify: true
46+
},
47+
mangle: true
48+
}),
49+
sourcemaps()
50+
];
51+
52+
const nodePlugins = [
53+
typescriptPlugin({
54+
typescript,
55+
compilerOptions: {
56+
allowJs: true
57+
},
58+
include: ['dist/*.js']
59+
}),
60+
sourcemaps()
61+
];
62+
63+
const browserBuilds = [
64+
{
65+
input: pkg.esm2017,
66+
output: { file: pkg.module, format: 'es', sourcemap: true },
67+
plugins: browserPlugins,
68+
external: resolveBrowserExterns
69+
},
70+
{
71+
input: path.resolve('./memory', memoryPkg.esm2017),
72+
output: {
73+
file: path.resolve('./memory', memoryPkg.module),
74+
format: 'es',
75+
sourcemap: true
76+
},
77+
plugins: browserPlugins,
78+
external: resolveBrowserExterns
79+
},
80+
{
81+
input: pkg.esm2017,
82+
output: { file: pkg.browser, format: 'cjs', sourcemap: true },
83+
plugins: browserPlugins,
84+
external: resolveBrowserExterns
85+
},
86+
{
87+
input: path.resolve('./memory', memoryPkg.esm2017),
88+
output: {
89+
file: path.resolve('./memory', memoryPkg.browser),
90+
format: 'cjs',
91+
sourcemap: true
92+
},
93+
plugins: browserPlugins,
94+
external: resolveBrowserExterns
95+
}
96+
];
97+
98+
const nodeBuilds = [
99+
{
100+
input: pkg['main-esm2017'],
101+
output: [{ file: pkg.main, format: 'cjs', sourcemap: true }],
102+
plugins: nodePlugins,
103+
external: resolveNodeExterns
104+
},
105+
{
106+
input: path.resolve('./memory', memoryPkg['main-esm2017']),
107+
output: [
108+
{
109+
file: path.resolve('./memory', memoryPkg.main),
110+
format: 'cjs',
111+
sourcemap: true
112+
}
113+
],
114+
plugins: nodePlugins,
115+
external: resolveNodeExterns
116+
}
117+
];
118+
119+
export default [...browserBuilds, ...nodeBuilds];

0 commit comments

Comments
 (0)