Skip to content

Commit 98f9aa4

Browse files
committed
Removed dynamic imports
1 parent 4c2baec commit 98f9aa4

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

CLAUDE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ containerTest("should use both", async ({ prisma, redisOptions }) => {
6666
});
6767
```
6868

69+
## Code Style
70+
71+
### Imports
72+
73+
**Prefer static imports over dynamic imports.** Only use dynamic `import()` when:
74+
- Circular dependencies cannot be resolved otherwise
75+
- Code splitting is genuinely needed for performance
76+
- The module must be loaded conditionally at runtime
77+
78+
Dynamic imports add unnecessary overhead in hot paths and make code harder to analyze. If you find yourself using `await import()`, ask if a regular `import` statement would work instead.
79+
6980
## Changesets and Server Changes
7081

7182
When modifying any public package (`packages/*` or `integrations/*`), add a changeset:

apps/webapp/app/v3/otlpExporter.server.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { waitForLlmPricingReady } from "./llmPricingRegistry.server";
4040
import { env } from "~/env.server";
4141
import { detectBadJsonStrings } from "~/utils/detectBadJsonStrings";
4242
import { singleton } from "~/utils/singleton";
43+
import { getClickhouseForOrganization, getEventRepositoryForOrganization } from "~/services/clickhouse/clickhouseFactory.server";
4344

4445
class OTLPExporter {
4546
private _tracer: Tracer;
@@ -149,9 +150,6 @@ class OTLPExporter {
149150
async #getEventRepositoryForStoreAndOrg(store: string, orgId: string): Promise<IEventRepository> {
150151
// For ClickHouse stores with a specific org (not "default"), use org-specific repository
151152
if ((store === "clickhouse" || store === "clickhouse_v2") && orgId !== "default") {
152-
const { getEventRepositoryForOrganization } = await import(
153-
"~/services/clickhouse/clickhouseFactory.server"
154-
);
155153
return await getEventRepositoryForOrganization(orgId);
156154
}
157155

@@ -1191,11 +1189,6 @@ export const otlpExporter = singleton("otlpExporter", initializeOTLPExporter);
11911189

11921190
async function initializeOTLPExporter() {
11931191
// Metrics are written globally (not per-org), use standard clickhouse
1194-
// We use a dummy org ID since metrics table is global
1195-
const { getClickhouseForOrganization } = await import(
1196-
"~/services/clickhouse/clickhouseFactory.server"
1197-
);
1198-
11991192
// Use a sentinel org ID for global metrics writes
12001193
// In practice, all orgs currently share the same metrics table/instance
12011194
const metricsClickhouse = await getClickhouseForOrganization("METRICS_GLOBAL", "standard");

0 commit comments

Comments
 (0)