Skip to content

Commit cf3bc66

Browse files
committed
Fix broken node tests
1 parent 6909478 commit cf3bc66

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

packages-exp/auth-compat-exp/index.node.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
export * from './index';
2525
import { FetchProvider } from '@firebase/auth-exp/internal';
2626
import * as fetchImpl from 'node-fetch';
27+
import './index';
2728

2829
FetchProvider.initialize(
2930
(fetchImpl.default as unknown) as typeof fetch,

packages-exp/auth-compat-exp/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function registerAuthCompat(instance: _FirebaseNamespace): void {
136136
.setMultipleInstances(false)
137137
);
138138

139-
instance.registerVersion('auth', version);
139+
instance.registerVersion('auth-compat', version);
140140
}
141141

142142
registerAuthCompat(firebase as _FirebaseNamespace);

packages-exp/auth-compat-exp/rollup.config.shared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function getEs5Builds(additionalTypescriptPlugins = {}) {
6565
plugins: es5BuildPlugins,
6666
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)),
6767
treeshake: {
68-
moduleSideEffects: false
68+
moduleSideEffects: true
6969
}
7070
},
7171
/**

packages-exp/auth-compat-exp/src/auth.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,22 @@ export class Auth
6161
appName: app.name
6262
});
6363

64-
// Note this is slightly different behavior: in this case, the stored
65-
// persistence is checked *first* rather than last. This is because we want
66-
// to prefer stored persistence type in the hierarchy.
67-
const persistences = _getPersistencesFromRedirect(apiKey, app.name);
64+
let persistences: exp.Persistence[] = [exp.inMemoryPersistence];
6865

69-
for (const persistence of [
70-
exp.indexedDBLocalPersistence,
71-
exp.browserLocalPersistence
72-
]) {
73-
if (!persistences.includes(persistence)) {
74-
persistences.push(persistence);
66+
// Only deal with persistences in web environments
67+
if (typeof window !== 'undefined') {
68+
// Note this is slightly different behavior: in this case, the stored
69+
// persistence is checked *first* rather than last. This is because we want
70+
// to prefer stored persistence type in the hierarchy.
71+
persistences = _getPersistencesFromRedirect(apiKey, app.name);
72+
73+
for (const persistence of [
74+
exp.indexedDBLocalPersistence,
75+
exp.browserLocalPersistence
76+
]) {
77+
if (!persistences.includes(persistence)) {
78+
persistences.push(persistence);
79+
}
7580
}
7681
}
7782

0 commit comments

Comments
 (0)