From 81bd9a601c1019feb2267458eb4418af84ca1cf6 Mon Sep 17 00:00:00 2001 From: Jeff Huleatt <3759507+jhuleatt@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:57:20 +0000 Subject: [PATCH 1/2] fix(build): preserve ESM modules so bundlers can tree-shake unused Firebase SDKs --- package.json | 1 + tsconfig.json | 2 +- vite.config.ts | 29 ++++++++++++++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6b6b707f..f2a72c82 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ } }, "typings": "dist/index.d.ts", + "sideEffects": false, "files": [ "dist", "src" diff --git a/tsconfig.json b/tsconfig.json index 7cb9a9dd..362ab873 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs "include": ["src", "types"], "compilerOptions": { - "target": "es2015", + "target": "es2024", "module": "esnext", "lib": ["dom", "esnext"], "types": ["vitest/globals"], diff --git a/vite.config.ts b/vite.config.ts index 30d83cb9..bfff2a9b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -18,6 +18,16 @@ const externals = [ // loads client-side in a Next.js App Router (strict ESM) context. Externalizing keeps // the shim's React 16/17 fallback intact while removing the require from our dist. 'use-sync-external-store/shim', + // Declared dependencies: let the consumer's bundler resolve (and dedupe/tree-shake) them instead of inlining a copy. + 'rxjs', + 'rxjs/operators', + 'rxfire/auth', + 'rxfire/database', + 'rxfire/firestore', + 'rxfire/functions', + 'rxfire/performance', + 'rxfire/remote-config', + 'rxfire/storage', 'firebase', 'firebase/app', 'firebase/firestore', @@ -67,9 +77,22 @@ export default defineConfig({ }, rollupOptions: { external: externals, - output: { - globals: { react: 'React' }, - }, + output: [ + // Emit one ES module per source file so `"sideEffects": false` lets bundlers drop unused products + // (and their `firebase/*` imports) instead of pulling every Firebase SDK in through a single index.js. + { + format: 'es', + preserveModules: true, + preserveModulesRoot: 'src', + entryFileNames: '[name].js', + }, + { + format: 'umd', + name: 'ReactFire', + entryFileNames: 'index.umd.cjs', + globals: { react: 'React' }, + }, + ], }, sourcemap: true, }, From b3b69e22301ef9fda96029a1a3ab32f347da5adb Mon Sep 17 00:00:00 2001 From: Jeff Huleatt <3759507+jhuleatt@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:57:59 +0000 Subject: [PATCH 2/2] chore(deps): require rxjs ^7.1.0 now that rxjs is externalized --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1e974b3b..87698f63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "rxfire": "^6.1.0", - "rxjs": "^6.6.3 || ^7.0.1", + "rxjs": "^7.1.0", "use-sync-external-store": "^1.2.0" }, "devDependencies": { diff --git a/package.json b/package.json index f2a72c82..02ccd7fb 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ }, "dependencies": { "rxfire": "^6.1.0", - "rxjs": "^6.6.3 || ^7.0.1", + "rxjs": "^7.1.0", "use-sync-external-store": "^1.2.0" }, "allowScripts": {