Skip to content

Commit 5559fd7

Browse files
Merge 4808d25 into 0986b92
2 parents 0986b92 + 4808d25 commit 5559fd7

File tree

4 files changed

+63
-45
lines changed

4 files changed

+63
-45
lines changed

packages/firestore/index.console.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
export { Firestore, FirestoreDatabase } from './src/api/database';
18+
export { Firestore } from './src/api/database';
1919
export {
2020
CollectionReference,
2121
DocumentReference,
@@ -24,7 +24,6 @@ export {
2424
} from './src/api/database';
2525
export { Blob } from './src/api/blob';
2626
export { GeoPoint } from './src/api/geo_point';
27-
export { FirstPartyCredentialsSettings } from './src/api/credentials';
2827
export { FieldPath } from './src/api/field_path';
2928
export { FieldValue } from './src/api/field_value';
3029
export { Timestamp } from './src/api/timestamp';

packages/firestore/rollup.shared.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ exports.es2017ToEs5Plugins = function (mangled = false) {
175175
return [
176176
typescriptPlugin({
177177
typescript,
178-
compilerOptions: {
179-
allowJs: true
178+
tsconfigOverride: {
179+
compilerOptions: {
180+
allowJs: true
181+
}
180182
},
181183
include: ['dist/*.js', 'dist/exp/*.js']
182184
}),
@@ -193,8 +195,10 @@ exports.es2017ToEs5Plugins = function (mangled = false) {
193195
return [
194196
typescriptPlugin({
195197
typescript,
196-
compilerOptions: {
197-
allowJs: true
198+
tsconfigOverride: {
199+
compilerOptions: {
200+
allowJs: true
201+
}
198202
},
199203
include: ['dist/*.js', 'dist/exp/*.js']
200204
}),

packages/firestore/src/api/credentials.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ import { logDebug } from '../util/log';
2929
// moved to an auth/ folder to match other platforms.
3030

3131
export interface FirstPartyCredentialsSettings {
32-
type: 'gapi';
33-
client: unknown;
34-
sessionIndex: string;
32+
// These are external types. Prevent minification.
33+
['type']: 'gapi';
34+
['client']: unknown;
35+
['sessionIndex']: string;
3536
}
3637

3738
export interface ProviderCredentialsSettings {
38-
type: 'provider';
39-
client: CredentialsProvider;
39+
// These are external types. Prevent minification.
40+
['type']: 'provider';
41+
['client']: CredentialsProvider;
4042
}
4143

4244
/** Settings for private credentials */
@@ -295,7 +297,8 @@ export class FirstPartyToken implements Token {
295297
const headers: { [header: string]: string } = {
296298
'X-Goog-AuthUser': this.sessionIndex
297299
};
298-
const authHeader = this.gapi.auth.getAuthHeaderValueForFirstParty([]);
300+
// Use array notation to prevent minification
301+
const authHeader = this.gapi['auth']['getAuthHeaderValueForFirstParty']([]);
299302
if (authHeader) {
300303
headers['Authorization'] = authHeader;
301304
}
@@ -336,9 +339,9 @@ export function makeCredentialsProvider(
336339
return new EmptyCredentialsProvider();
337340
}
338341

339-
switch (credentials.type) {
342+
switch (credentials['type']) {
340343
case 'gapi':
341-
const client = credentials.client as Gapi;
344+
const client = credentials['client'] as Gapi;
342345
// Make sure this really is a Gapi client.
343346
hardAssert(
344347
!!(
@@ -351,11 +354,11 @@ export function makeCredentialsProvider(
351354
);
352355
return new FirstPartyCredentialsProvider(
353356
client,
354-
credentials.sessionIndex || '0'
357+
credentials['sessionIndex'] || '0'
355358
);
356359

357360
case 'provider':
358-
return credentials.client;
361+
return credentials['client'];
359362

360363
default:
361364
throw new FirestoreError(

packages/firestore/tools/console.build.js

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,51 @@
2020
* This file creates a build target for it.
2121
*/
2222
const rollup = require('rollup');
23-
const typescriptPlugin = require('rollup-plugin-typescript2');
24-
const typescript = require('typescript');
25-
const json = require('rollup-plugin-json');
26-
const alias = require('@rollup/plugin-alias');
27-
const resolve = require('rollup-plugin-node-resolve');
2823
const { uglify } = require('rollup-plugin-uglify');
24+
const resolve = require('rollup-plugin-node-resolve');
2925
const fs = require('fs');
3026
const util = require('util');
3127
const fs_writeFile = util.promisify(fs.writeFile);
3228

3329
const rollupUtil = require('../rollup.shared');
3430

35-
const plugins = [
36-
alias(rollupUtil.generateAliasConfig('browser')),
37-
resolve(),
38-
typescriptPlugin({
39-
typescript
40-
}),
41-
json(),
42-
uglify({
43-
output: {
44-
ascii_only: true // escape unicode chars
45-
}
46-
})
47-
];
48-
4931
const EXPORTNAME = '__firestore_exports__';
5032

51-
const inputOptions = {
33+
const esm2017OutputFile = 'dist/standalone.esm2017.js';
34+
const esm5OutputFile = 'dist/standalone.js';
35+
36+
const es2017InputOptions = {
5237
input: 'index.console.ts',
53-
plugins
38+
plugins: rollupUtil.es2017Plugins('browser', /* mangled= */ true),
39+
external: rollupUtil.resolveBrowserExterns,
40+
treeshake: {
41+
moduleSideEffects: false
42+
}
43+
};
44+
45+
const es2017OutputOptions = {
46+
file: esm2017OutputFile,
47+
format: 'es'
48+
};
49+
50+
const es2017toEs5InputOptions = {
51+
input: esm2017OutputFile,
52+
plugins: [
53+
resolve(),
54+
...rollupUtil.es2017ToEs5Plugins(/* mangled= */ true),
55+
uglify({
56+
output: {
57+
ascii_only: true // escape unicode chars
58+
}
59+
})
60+
],
61+
treeshake: {
62+
moduleSideEffects: false
63+
}
5464
};
55-
const outputOptions = {
56-
file: 'dist/standalone.js',
65+
66+
const es2017toEs5OutputOptions = {
67+
file: esm5OutputFile,
5768
name: EXPORTNAME,
5869
format: 'iife'
5970
};
@@ -65,17 +76,18 @@ exports = eval(`;
6576
const POSTFIX = ` + '${EXPORTNAME};');`;
6677

6778
async function build() {
68-
// create a bundle
69-
const bundle = await rollup.rollup(inputOptions);
79+
// Create an ES2017 bundle
80+
const es2017Bundle = await rollup.rollup(es2017InputOptions);
81+
await es2017Bundle.write(es2017OutputOptions);
7082

71-
// generate code
83+
// Transpile down to ES5
84+
const es5Bundle = await rollup.rollup(es2017toEs5InputOptions);
7285
const {
7386
output: [{ code }]
74-
} = await bundle.generate(outputOptions);
87+
} = await es5Bundle.generate(es2017toEs5OutputOptions);
7588

7689
const output = `${PREFIX}${JSON.stringify(String(code))}${POSTFIX}`;
77-
78-
await fs_writeFile(outputOptions.file, output, 'utf-8');
90+
await fs_writeFile(es2017toEs5OutputOptions.file, output, 'utf-8');
7991
}
8092

8193
build();

0 commit comments

Comments
 (0)