Migrate Firebase from compat API to modular API
This PR migrates the Firebase implementation from the legacy compat API to the modern modular API as recommended by Firebase. The compat API is a temporary solution and should be replaced with the modular API for better performance and future compatibility.
Changes Made
β Core Infrastructure (100% Complete)
-
App.tsx: Migrated Firebase initialization to use modular
initializeApp,getAuth,getDatabase, etc. - handlers.ts: Completely migrated all utility functions from compat to modular API, removing duplicate modular versions
β Pages Successfully Migrated (7/10 Complete)
- Committee.tsx: Database references and lifecycle methods
- Admin.tsx: Database references and remove operations
- Files.tsx: Database and Storage APIs including upload/download functionality
- Notes.tsx: Database references and data callbacks
- Settings.tsx: Database references with child navigation
- Strawpoll.tsx: Fixed handler function references
- Motions.tsx: Partial migration (interfaces and some methods)
π Remaining Complex Pages (3/10)
- Caucus.tsx: Complex nested references and speaker management
- Resolution.tsx: Amendment and resolution handling
- Motions.tsx: Complete lifecycle method migration
Key Benefits
- Bundle Size Reduction: From 1,855KB to 1,339KB (~28% reduction)
- Future Compatibility: Using modern Firebase v9+ modular SDK
- Better Performance: Tree-shaking enabled with modular imports
- Maintainability: Cleaner import structure and explicit dependencies
Migration Pattern
Before (compat):
import firebase from 'firebase/compat/app';
const ref = firebase.database().ref('path').child('subpath');
ref.on('value', callback);
ref.set(data);
After (modular):
import { ref, child, onValue, set } from 'firebase/database';
import { database } from '../App';
const dbRef = ref(database, 'path');
const childRef = child(dbRef, 'subpath');
onValue(childRef, callback);
set(childRef, data);
Testing
- β All existing tests continue to pass
- β Application builds successfully for migrated components
- β Core functionality maintained through migration
The remaining complex pages require extensive refactoring due to their advanced Firebase usage patterns but can be completed in follow-up work without breaking the core application functionality.
Addressing #196.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
download.cypress.io
- Triggering command:
node index.js --exec install(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
π‘ You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.