Skip to content

Commit 52ff029

Browse files
committed
fix(webapp): pass isProduction into StaleAssetRecovery as a prop
1 parent 5f61600 commit 52ff029

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

apps/webapp/app/components/StaleAssetRecovery.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ const script = `(function () {
4747
});
4848
})();`;
4949

50-
export function StaleAssetRecovery() {
51-
if (process.env.NODE_ENV !== "production") {
50+
export function StaleAssetRecovery({ isProduction }: { isProduction: boolean }) {
51+
if (!isProduction) {
5252
return null;
5353
}
5454

apps/webapp/app/root.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ import { getUser } from "./services/session.server";
1919
import { getTimezonePreference } from "./services/preferences/uiPreferences.server";
2020
import { appEnvTitleTag } from "./utils";
2121

22+
// Derived here (not inside StaleAssetRecovery) so the shared component takes
23+
// the flag as a prop. NODE_ENV is statically replaced in browser bundles, and
24+
// the ErrorBoundary can't rely on loader data.
25+
const isProduction = process.env.NODE_ENV === "production";
26+
2227
export const links: LinksFunction = () => {
2328
return [{ rel: "stylesheet", href: tailwindStylesheetUrl }];
2429
};
@@ -98,7 +103,7 @@ export function ErrorBoundary() {
98103
<head>
99104
<meta charSet="utf-8" />
100105

101-
<StaleAssetRecovery />
106+
<StaleAssetRecovery isProduction={isProduction} />
102107
<Meta />
103108
<Links />
104109
</head>
@@ -125,7 +130,7 @@ export default function App() {
125130
<>
126131
<html lang="en" className="h-full">
127132
<head>
128-
<StaleAssetRecovery />
133+
<StaleAssetRecovery isProduction={isProduction} />
129134
<Meta />
130135
<Links />
131136
</head>

0 commit comments

Comments
 (0)