Skip to content

Commit 2f21579

Browse files
WIP
1 parent be2671d commit 2f21579

File tree

4 files changed

+35
-23
lines changed

4 files changed

+35
-23
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: 11 additions & 9 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 */
@@ -336,9 +338,9 @@ export function makeCredentialsProvider(
336338
return new EmptyCredentialsProvider();
337339
}
338340

339-
switch (credentials.type) {
341+
switch (credentials['type']) {
340342
case 'gapi':
341-
const client = credentials.client as Gapi;
343+
const client = credentials['client'] as Gapi;
342344
// Make sure this really is a Gapi client.
343345
hardAssert(
344346
!!(
@@ -351,11 +353,11 @@ export function makeCredentialsProvider(
351353
);
352354
return new FirstPartyCredentialsProvider(
353355
client,
354-
credentials.sessionIndex || '0'
356+
credentials['sessionIndex'] || '0'
355357
);
356358

357359
case 'provider':
358-
return credentials.client;
360+
return credentials['client'];
359361

360362
default:
361363
throw new FirestoreError(

packages/firestore/tools/console.build.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* Firebase console uses firestore in its special way.
2020
* This file creates a build target for it.
2121
*/
22-
const tmp = require('tmp');
2322
const rollup = require('rollup');
23+
const { uglify } = require('rollup-plugin-uglify');
2424
const fs = require('fs');
2525
const util = require('util');
2626
const fs_writeFile = util.promisify(fs.writeFile);
@@ -29,35 +29,43 @@ const rollupUtil = require('../rollup.shared');
2929

3030
const EXPORTNAME = '__firestore_exports__';
3131

32-
const tmpFile = tmp.fileSync().name;
32+
const esm2017OutputFile = 'dist/standalone.esm2017.js';
33+
const esm5OutputFile = 'dist/standalone.js';
3334

3435
const es2017InputOptions = {
3536
input: 'index.console.ts',
3637
// If I set mangled to true the build breaks, but all other build pipelines
3738
// use the same settings
38-
plugins: rollupUtil.es2017Plugins('browser', /* mangled= */ false),
39+
plugins: rollupUtil.es2017Plugins('browser', /* mangled= */ true),
3940
external: rollupUtil.resolveBrowserExterns,
4041
treeshake: {
4142
moduleSideEffects: false
4243
}
4344
};
4445

4546
const es2017OutputOptions = {
46-
file: tmpFile,
47+
file: esm2017OutputFile,
4748
format: 'es'
4849
};
4950

5051
const es2017toEs5InputOptions = {
51-
input: tmpFile,
52-
plugins: rollupUtil.es2017ToEs5Plugins(/* mangled= */ true),
52+
input: esm2017OutputFile,
53+
plugins: [
54+
...rollupUtil.es2017ToEs5Plugins(/* mangled= */ true),
55+
uglify({
56+
output: {
57+
ascii_only: true // escape unicode chars
58+
}
59+
})
60+
],
5361
external: rollupUtil.resolveBrowserExterns,
5462
treeshake: {
5563
moduleSideEffects: false
5664
}
5765
};
5866

5967
const es2017toEs5OutputOptions = {
60-
file: 'dist/standalone.js',
68+
file: esm5OutputFile,
6169
name: EXPORTNAME,
6270
format: 'iife'
6371
};
@@ -72,7 +80,6 @@ async function build() {
7280
// create an ES2017 bundle
7381
const es2017Bundle = await rollup.rollup(es2017InputOptions);
7482
await es2017Bundle.write(es2017OutputOptions);
75-
console.log(tmpFile);
7683

7784
const es5Bundle = await rollup.rollup(es2017toEs5InputOptions);
7885
const {

0 commit comments

Comments
 (0)