Skip to content

Make compat script work #3916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions packages-exp/app-compat/src/firebaseNamespaceCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@ import {
FirebaseService,
FirebaseServiceNamespace
} from '@firebase/app-types/private';
import {
SDK_VERSION,
initializeApp,
registerVersion,
onLog,
setLogLevel,
_registerComponent,
_DEFAULT_ENTRY_NAME
} from '@firebase/app-exp';
import * as modularAPIs from '@firebase/app-exp';
import { _FirebaseAppInternal } from '@firebase/app-types-exp';
import { Component, ComponentType } from '@firebase/component';

Expand Down Expand Up @@ -66,16 +58,17 @@ export function createFirebaseNamespaceCore(
initializeApp: initializeAppCompat,
// @ts-ignore
app,
registerVersion,
setLogLevel,
onLog,
registerVersion: modularAPIs.registerVersion,
setLogLevel: modularAPIs.setLogLevel,
onLog: modularAPIs.onLog,
// @ts-ignore
apps: null,
SDK_VERSION,
SDK_VERSION: modularAPIs.SDK_VERSION,
INTERNAL: {
registerComponent: registerComponentCompat,
removeApp,
useAsService
useAsService,
modularAPIs
}
};

Expand Down Expand Up @@ -109,7 +102,7 @@ export function createFirebaseNamespaceCore(
* Get the App object for a given name (or DEFAULT).
*/
function app(name?: string): FirebaseApp {
name = name || _DEFAULT_ENTRY_NAME;
name = name || modularAPIs._DEFAULT_ENTRY_NAME;
if (!contains(apps, name)) {
throw ERROR_FACTORY.create(AppError.NO_APP, { appName: name });
}
Expand All @@ -126,7 +119,10 @@ export function createFirebaseNamespaceCore(
options: FirebaseOptions,
rawConfig = {}
): FirebaseApp {
const app = initializeApp(options, rawConfig) as _FirebaseAppInternal;
const app = modularAPIs.initializeApp(
options,
rawConfig
) as _FirebaseAppInternal;
const appCompat = new firebaseAppImpl(app, namespace as _FirebaseNamespace);
apps[app.name] = appCompat;
return appCompat;
Expand All @@ -145,7 +141,7 @@ export function createFirebaseNamespaceCore(
): FirebaseServiceNamespace<FirebaseService> | null {
const componentName = component.name;
if (
_registerComponent(component) &&
modularAPIs._registerComponent(component) &&
component.type === ComponentType.PUBLIC
) {
// create service namespace for public components
Expand Down
5 changes: 3 additions & 2 deletions packages-exp/auth-compat-exp/demo/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const umdBuilds = [
extend: true,
name: 'firebase',
globals: {
'@firebase/app-compat': 'firebase'
'@firebase/app-compat': 'firebase',
'@firebase/app-exp': 'firebase.INTERNAL.modularAPIs'
},
/**
* use iife to avoid below error in the old Safari browser
Expand All @@ -81,7 +82,7 @@ const umdBuilds = [
}`
},
plugins: [...plugins],
external: ['@firebase/app-compat']
external: ['@firebase/app-compat', '@firebase/app-exp']
}
];

Expand Down