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.

feat(exporter): split exporter shared chunk via anchors and dynamic hogql parser (#58071)

Paul D'Ambra53735ee072d1
diff --git a/frontend/build.mjs b/frontend/build.mjs
index cd15e130b800..0791c6fe47cb 100755
--- a/frontend/build.mjs
+++ b/frontend/build.mjs
@@ -79,7 +79,10 @@ await buildInParallel(
},
{
name: 'Exporter',
- entryPoints: { exporter: 'src/exporter/index.tsx' },
+ entryPoints: {
+ exporter: 'src/exporter/index.tsx',
+ exporterSharedChunkAnchors: 'src/sharedChunkAnchors.ts',
+ },
splitting: true,
format: 'esm',
outdir: path.resolve(__dirname, 'dist'),
@@ -122,6 +125,9 @@ await buildInParallel(
}
if (config.name === 'Exporter') {
+ if (!isDev) {
+ reportTopChunks(buildResponse.outputs, { label: 'Exporter chunks' })
+ }
writeExporterHtml(chunks, entrypoints)
}
diff --git a/frontend/src/scenes/data-warehouse/editor/hogqlParserSingleton.ts b/frontend/src/scenes/data-warehouse/editor/hogqlParserSingleton.ts
index 7e364651f009..d2ae643d3ba3 100644
--- a/frontend/src/scenes/data-warehouse/editor/hogqlParserSingleton.ts
+++ b/frontend/src/scenes/data-warehouse/editor/hogqlParserSingleton.ts
@@ -1,14 +1,16 @@
-import createHogQLParser, { type HogQLParser } from '@posthog/hogql-parser'
+import type { HogQLParser } from '@posthog/hogql-parser'
let parserPromise: Promise<HogQLParser> | null = null
function getParser(): Promise<HogQLParser> {
if (!parserPromise) {
- parserPromise = createHogQLParser().catch((error) => {
- // Reset so next call retries initialization
- parserPromise = null
- throw error
- })
+ parserPromise = import('@posthog/hogql-parser')
+ .then((mod) => mod.default())
+ .catch((error) => {
+ // Reset so next call retries initialization
+ parserPromise = null
+ throw error
+ })
}
return parserPromise
}