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.

fix(devex): force ESM loading for vite.config to fix start-vite (#57662)

Adam Leith3d2df32f066a
diff --git a/frontend/plugins/vite-public-assets-plugin.ts b/frontend/plugins/vite-public-assets-plugin.ts
index d54ee983a719..36d4feb29528 100644
--- a/frontend/plugins/vite-public-assets-plugin.ts
+++ b/frontend/plugins/vite-public-assets-plugin.ts
@@ -1,4 +1,4 @@
-import { existsSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from 'fs'
+import { existsSync, mkdirSync, readFileSync, readdirSync, rmdirSync, unlinkSync, writeFileSync } from 'fs'
import { dirname, join, relative, resolve } from 'path'
import type { Plugin } from 'vite'
@@ -37,7 +37,7 @@ function deleteDirectory(dirPath: string): void {
}
})
// Remove the empty directory
- require('fs').rmdirSync(dirPath)
+ rmdirSync(dirPath)
} catch (error) {
console.warn(`⚠️ Could not delete directory ${dirPath}:`, error)
}
diff --git a/frontend/vite.config.ts b/frontend/vite.config.mts
similarity index 98%
rename from frontend/vite.config.ts
rename to frontend/vite.config.mts
index 4308586b1ee3..8ec5c5609bf8 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.mts
@@ -1,9 +1,11 @@
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
+import { dirname, resolve } from 'node:path'
import { URL, fileURLToPath } from 'node:url'
-import { resolve } from 'path'
import { defineConfig } from 'vite'
+const __dirname = dirname(fileURLToPath(import.meta.url))
+
// import { toolbarDenylistPlugin } from './vite-toolbar-plugin'
import { htmlGenerationPlugin } from './plugins/vite-html-plugin'
import { posthogJsPlugin } from './plugins/vite-posthog-js-plugin'
diff --git a/package.json b/package.json
index 0166d75305ca..119afa7cb22e 100644
--- a/package.json
+++ b/package.json
@@ -91,8 +91,8 @@
"bin/hogli lint:feature-flags:fix",
"bin/hogli format:js"
],
- "{playwright,frontend,products,common,ee,services,docs}/**/*.{js,jsx,mjs,ts,tsx}": "bin/hogli format:js",
- "nodejs/**/*.{js,jsx,mjs,ts,tsx}": "bin/hogli format:nodejs",
+ "{playwright,frontend,products,common,ee,services,docs}/**/*.{js,jsx,mjs,mts,ts,tsx}": "bin/hogli format:js",
+ "nodejs/**/*.{js,jsx,mjs,mts,ts,tsx}": "bin/hogli format:nodejs",
"funnel-udf/**/*.rs": "bin/hogli format:rust",
"!(posthog/hogql/grammar/*|posthog/personhog_client/proto/generated/*|products/*/skills/*/scripts/*)*.{py,pyi}": [
"bin/hogli lint:python:fix",