Skip to content

Open source alternative to Semrush and Ahrefs

Keep the billing usage chart out of the shared entry bundle (#924)

Carter Smith4c4dbffbc024
diff --git a/src/client/features/billing/BillingTabs.tsx b/src/client/features/billing/BillingTabs.tsx
index 3fa21f78..9fdd2f7c 100644
--- a/src/client/features/billing/BillingTabs.tsx
+++ b/src/client/features/billing/BillingTabs.tsx
@@ -4,12 +4,7 @@ import { TabsTrigger } from "@/client/components/ui/tabs";
import { BillingFeatureBreakdown } from "@/client/features/billing/BillingFeatureBreakdown";
import { BillingInvoices } from "@/client/features/billing/BillingInvoices";
import { BillingUsageChart } from "@/client/features/billing/BillingUsageChart";
-
-export const BILLING_TABS = [
- { value: "usage", label: "Usage" },
- { value: "invoices", label: "Invoices" },
-] as const;
-type BillingTab = (typeof BILLING_TABS)[number]["value"];
+import { BILLING_TABS, type BillingTab } from "@/shared/billing";
/**
* Usage and, for owners, invoices in one card with a tab row. Members see
diff --git a/src/routes/_app/billing.tsx b/src/routes/_app/billing.tsx
index d6ce43f2..14b44be3 100644
--- a/src/routes/_app/billing.tsx
+++ b/src/routes/_app/billing.tsx
@@ -28,10 +28,7 @@ import {
openUpgradeCheckout,
prefetchUpgradeCheckout,
} from "@/client/features/billing/checkout";
-import {
- BILLING_TABS,
- BillingTabs,
-} from "@/client/features/billing/BillingTabs";
+import { BillingTabs } from "@/client/features/billing/BillingTabs";
import { parseTopUpAmount } from "@/client/features/billing/HostedBillingContentUtils";
import { billingUsageEventsQueryOptions } from "@/client/features/billing/useBillingUsageEvents";
import { useCreditBalance } from "@/client/features/billing/useCreditBalance";
@@ -44,7 +41,7 @@ import {
createBillingPortalSession,
createTopUpCheckout,
} from "@/serverFunctions/billing";
-import { BILLING_ROUTE } from "@/shared/billing";
+import { BILLING_ROUTE, BILLING_TABS } from "@/shared/billing";
export const Route = createFileRoute("/_app/billing")({
validateSearch: z.object({
diff --git a/src/shared/billing.ts b/src/shared/billing.ts
index 319feadd..ec949c6b 100644
--- a/src/shared/billing.ts
+++ b/src/shared/billing.ts
@@ -1,6 +1,15 @@
export const BILLING_ROUTE = "/billing";
export const SUBSCRIBE_ROUTE = "/subscribe";
+// Billing page tabs. Here rather than in BillingTabs.tsx because the route's
+// validateSearch reads them, and route options aren't code-split: importing
+// the component would pull its chart into the entry chunk.
+export const BILLING_TABS = [
+ { value: "usage", label: "Usage" },
+ { value: "invoices", label: "Invoices" },
+] as const;
+export type BillingTab = (typeof BILLING_TABS)[number]["value"];
+
export type PlanStatus = "free" | "paid";
export const AUTUMN_PAID_PLAN_ID = "base-plan";