Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

perf(frontend): keep zod locales off the authenticated shell (#105031)

Paul D'Ambrabca50279d4b6
diff --git a/common/esbuilder/utils.mjs b/common/esbuilder/utils.mjs
index 16ac470fc459..135beba142b3 100644
--- a/common/esbuilder/utils.mjs
+++ b/common/esbuilder/utils.mjs
@@ -222,6 +222,20 @@ export const commonConfig = {
})
},
},
+ // zod re-exports every error-message locale as `z.locales`. Any import that keeps the whole
+ // `z` object (a named `z` import, the default import, a shared chunk anchor) then ships all
+ // of them. We only use `en`, which zod imports directly, so the locales barrel exports `en`
+ // only. The eager graph check has a tripwire for another locale file in case the path moves.
+ {
+ name: 'zod-en-locale-only',
+ setup(build) {
+ build.onLoad({ filter: /[\\/]zod[\\/]v4[\\/]locales[\\/]index\.js$/ }, (args) => ({
+ contents: 'export { default as en } from "./en.js";',
+ loader: 'js',
+ resolveDir: path.dirname(args.path),
+ }))
+ },
+ },
sassPlugin({
async transform(source, resolveDir, filePath) {
const plugins = [tailwindcss, autoprefixer, postcssPresetEnv({ stage: 0 })]
diff --git a/frontend/bin/check-eager-graph.mjs b/frontend/bin/check-eager-graph.mjs
index be01f9c89ec7..7057c6c36f1b 100644
--- a/frontend/bin/check-eager-graph.mjs
+++ b/frontend/bin/check-eager-graph.mjs
@@ -102,6 +102,13 @@ const ROOTS = [
verifyPrefix: 'products/dashboards/frontend/widgets/',
},
'src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts',
+ // The zod-en-locale-only plugin in common/esbuilder/utils.mjs keeps every locale except
+ // `en` out of the build. A hit on another locale means zod moved its locales barrel and
+ // the plugin no longer matches it.
+ {
+ pattern: 'zod/v4/locales/de.js',
+ verifyPrefix: 'zod/v4/locales/en.js',
+ },
// See the entry root's note: inline-SVG hoggies must stay off the eager path.
{
pattern: 'node_modules/@posthog/brand/dist/generated/hoggies/svg/',