Skip to content

Commit 2d67c44

Browse files
committed
fix(react): Statically replace import.meta.env at build time
1 parent fb9676d commit 2d67c44

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"scripts": {
1919
"prepare": "pnpm run build",
20-
"build": "tsup && pnpm run build:logos",
20+
"build": "tsup --env.PROD=true && pnpm run build:logos",
2121
"build:local": "pnpm run build && pnpm pack",
2222
"build:logos": "pnpm dlx @svgr/cli --icon --typescript --no-index --jsx-runtime automatic --out-dir src/components/logos ../core/brands",
2323
"dev": "tsup --watch",

packages/react/src/index.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@ export { PolicyContext } from "./components/policies";
2424
export { FirebaseUIProvider, type FirebaseUIProviderProps } from "./context";
2525
export * from "./hooks";
2626

27-
// Detect production mode across different build systems (Vite, webpack/Next.js, etc.)
28-
const isNodeProduction = typeof process !== "undefined" && process.env.NODE_ENV === "production";
29-
30-
const isViteProduction =
31-
typeof import.meta !== "undefined" &&
32-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
33-
(import.meta as any)?.env &&
34-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
35-
(import.meta as any).env.PROD === true;
36-
37-
// Check if in production mode
38-
const isProduction = isNodeProduction || isViteProduction;
39-
40-
if (isProduction) {
41-
// Extract framework name from package name (e.g., "@invertase/firebaseui-react" -> "react")
42-
const frameworkName = pkgJson.name.replace("@invertase/firebaseui-", "");
43-
registerFramework(frameworkName, pkgJson.version);
27+
if (import.meta.env.PROD) {
28+
registerFramework("react", pkgJson.version);
4429
}

0 commit comments

Comments
 (0)