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): stub out fs/promises in the browser build (#119024)

Paul D'Ambra202ac1617e89
diff --git a/common/esbuilder/utils.mjs b/common/esbuilder/utils.mjs
index 3ccf683697ae..3ddc45799147 100644
--- a/common/esbuilder/utils.mjs
+++ b/common/esbuilder/utils.mjs
@@ -320,6 +320,8 @@ export const commonConfig = {
polyfills: {
buffer: false,
crypto: false,
+ // The plugin stubs out fs by default but not fs/promises, which would pull in the whole fs polyfill.
+ 'fs/promises': 'empty',
process: true,
stream: false,
},
diff --git a/frontend/bin/check-eager-graph.mjs b/frontend/bin/check-eager-graph.mjs
index 155841ec75f2..911be368c93c 100644
--- a/frontend/bin/check-eager-graph.mjs
+++ b/frontend/bin/check-eager-graph.mjs
@@ -203,6 +203,9 @@ const ROOTS = [
// The player shows a snapshot of a few settings. A hit means it imports settingsLogic again,
// which holds every settings page.
'src/scenes/settings/SettingsMap.tsx',
+ // A browser cannot read files. The polyfill plugin in common/esbuilder/utils.mjs stubs out
+ // fs and fs/promises, and a hit means a library's file reader pulled in the jspm fs polyfill.
+ '@jspm/core/nodelibs/browser/fs',
],
},
]