Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Previously,
vite.config.tsbundled all ofsrc/*into a single monolithicdist/index.jsthat imported every Firebase product (firebase/firestore,firebase/auth,firebase/database,firebase/storage,firebase/functions,firebase/remote-config,firebase/performance) at the top of one file. Because all product imports lived inside a single pre-bundled chunk, consumer bundlers could not tree-shake unused Firebase SDKs or split them behindReact.lazy.This PR:
preserveModules: true, preserveModulesRoot: 'src', entryFileNames: '[name].js') alongsidedist/index.umd.cjs.rxjs,rxjs/operators, andrxfire/*(declared independencies) so consumer bundlers resolve and tree-shake them directly instead of inlining a duplicate copy."rxjs"independenciesfrom"^6.6.3 || ^7.0.1"to"^7.1.0"so external resolution always provides RxJS ≥ 7.1 (required byshare({ resetOnRefCountZero: () => timer(...) }))."sideEffects": falsetopackage.json."target": "es2024"intsconfig.json(Baseline-certified) so TypeScript does not inject virtual_tslib.jshelper chunks underpreserveModules: true.Bundle Size Impact
Measured with Vite 8.3.5 production builds against
firebase@13.1.0(gzip -9of the emitted application bundle):reactfire@4.2.6(main)preserveModules: true)4.2.6useUser)95,988 B)269,074 B) — bundles Firestore, RTDB, Storage, Perf, Functions, RC103,791 B) — onlyfirebase/auth+rxjs+rxfire/authuseFirestoreCollection)206,792 B)279,049 B) — bundles Auth, RTDB, Storage, Perf, Functions, RC214,541 B) — onlyfirebase/firestore+rxjs+rxfire/firestoreBackwards Compatibility & Release Notes
import * as RF from 'reactfire'(dist/index.js) andrequire('reactfire')(dist/index.umd.cjs) expose the exact same 74 named exports asv4.2.6.package.json"main"(dist/index.umd.cjs),"exports"("." -> { "import": "./dist/index.js", "require": "./dist/index.umd.cjs" }), and"typings"(dist/index.d.ts) are unchanged."sideEffects": false: AllglobalThiscaches (_reactFirePreloadedObservables,_reactFireFirestoreQueryCache,_reactFireDatabaseCachedQueries) are initialized inside the modules that read them (useObservable.ts,firestore.tsx,database.tsx), so dropping an unused product module (e.g.,dist/database.jsordist/performance.js) never drops state needed by used modules.rxjs^7.1.0): Becauserxjsis a regular dependency (andv4.2.6already bundledrxjs@7.8.1), runtime behavior andnpm installare unchanged. However, TypeScript applications still onrxjs@6that pass their own customObservableinstances directly intouseObservableorpreloadObservablewill need to upgrade torxjs@^7.1.0so TypeScript'sObservabletypes match.Closes #489
Closes #488
Refs #480