in tools/build.ts [29:124]
function zoneWrapExports() {
const reexport = async (
module: string,
name: string,
path: string,
exports: string[],
overrides: Record<string, OverrideOptions|null> = {}
) => {
const imported = await import(path);
const toBeExported: Array<[string, string, boolean]> = exports.
filter(it => !it.startsWith('_') && overrides[it] !== null && overrides[it]?.override !== true).
map(importName => {
const zoneWrap = typeof imported[importName] === 'function' &&
(overrides[importName]?.zoneWrap ?? importName[0] !== importName[0].toUpperCase());
const exportName = overrides[importName]?.exportName ?? importName;
return [importName, exportName, zoneWrap];
});
const zoneWrapped = toBeExported.filter(([, , zoneWrap]) => zoneWrap);
const rawExport = toBeExported.filter(([, , zoneWrap]) => !zoneWrap);
const overridden = Object.keys(overrides).filter(key => overrides[key]?.override);
await writeFile(join(process.cwd(), 'src', `${module}/${name}.ts`), `// DO NOT MODIFY, this file is autogenerated by tools/build.ts
${path.startsWith('firebase/') ? `export * from '${path}';\n` : ''}${
zoneWrapped.length > 0 ? `import { ɵzoneWrap } from '@angular/fire';
import {
${zoneWrapped.map(([importName]) => `${importName} as _${importName}`).join(',\n ')}
} from '${path}';
` : ''}${!path.startsWith('firebase/') && rawExport.length > 0 ? `
export {
${rawExport.map(([importName, exportName]) => `${importName}${exportName === importName ? '' : `as ${exportName}`}`).join(',\n ')}
} from '${path}';
` : ''}${overridden.length > 0 ? `
export {
${overridden.join(',\n ')}
} from './overrides';
` : ''}
${zoneWrapped.map(([importName, exportName]) => `export const ${exportName} = ɵzoneWrap(_${importName}, ${overrides[importName]?.blockUntilFirst ?? true});`).join('\n')}
`); };
return Promise.all([
reexport('analytics', 'firebase', 'firebase/analytics', tsKeys<typeof import('firebase/analytics')>(), {
isSupported: { override: true },
}),
reexport('app', 'firebase', 'firebase/app', tsKeys<typeof import('firebase/app')>()),
reexport('app-check', 'firebase', 'firebase/app-check', tsKeys<typeof import('firebase/app-check')>()),
reexport('auth', 'rxfire', 'rxfire/auth', tsKeys<typeof import('rxfire/auth')>()),
reexport('auth', 'firebase', 'firebase/auth', tsKeys<typeof import('firebase/auth')>(), {
debugErrorMap: null,
inMemoryPersistence: null,
browserLocalPersistence: null,
browserSessionPersistence: null,
indexedDBLocalPersistence: null,
prodErrorMap: null,
}),
reexport('database', 'rxfire', 'rxfire/database', tsKeys<typeof import('rxfire/database')>()),
reexport('database', 'firebase', 'firebase/database', tsKeys<typeof import('firebase/database')>()),
reexport('firestore', 'rxfire', 'rxfire/firestore', tsKeys<typeof import('rxfire/firestore')>(), {
doc: { exportName: 'docSnapshots' },
collection: { exportName: 'collectionSnapshots' },
}),
reexport('firestore', 'firebase', 'firebase/firestore', tsKeys<typeof import('firebase/firestore')>()),
reexport('functions', 'rxfire', 'rxfire/functions', tsKeys<typeof import('rxfire/functions')>(), {
httpsCallable: { exportName: 'httpsCallableData' },
}),
reexport('functions', 'firebase', 'firebase/functions', tsKeys<typeof import('firebase/functions')>()),
reexport('messaging', 'firebase', 'firebase/messaging', tsKeys<typeof import('firebase/messaging')>(), {
onMessage: { blockUntilFirst: false },
isSupported: { override: true },
}),
reexport('remote-config', 'rxfire', 'rxfire/remote-config', tsKeys<typeof import('rxfire/remote-config')>(), {
getValue: { exportName: 'getValueChanges' },
getString: { exportName: 'getStringChanges' },
getNumber: { exportName: 'getNumberChanges' },
getBoolean: { exportName: 'getBooleanChanges' },
getAll: { exportName: 'getAllChanges' },
}),
reexport('remote-config', 'firebase', 'firebase/remote-config', tsKeys<typeof import('firebase/remote-config')>(), {
isSupported: { override: true },
}),
reexport('storage', 'rxfire', 'rxfire/storage', tsKeys<typeof import('rxfire/storage')>(), {
getDownloadURL: null,
getMetadata: null,
uploadBytesResumable: null,
uploadString: null,
}),
reexport('storage', 'firebase', 'firebase/storage', tsKeys<typeof import('firebase/storage')>()),
reexport('performance', 'rxfire', 'rxfire/performance', tsKeys<typeof import('rxfire/performance')>(), {
getPerformance$: null,
trace: null,
}),
reexport('performance', 'firebase', 'firebase/performance', tsKeys<typeof import('firebase/performance')>()),
reexport('firestore/lite', 'rxfire', 'rxfire/firestore/lite', tsKeys<typeof import('rxfire/firestore/lite')>(), {
doc: { exportName: 'docSnapshots' },
collection: { exportName: 'collectionSnapshots' },
}),
reexport('firestore/lite', 'firebase', 'firebase/firestore/lite', tsKeys<typeof import('firebase/firestore/lite')>()),
]);
}