fix(perf): actually produce a React profiling build

DevTools still reported "Profiling not supported" because the build was never a
profiling one, despite three settings appearing to enable it. Next applies the React
swap through a webpack alias — getReactProfilingInProduction, mapping
'react-dom/client$' to 'react-dom/profiling' — that Turbopack never sees. A Turbopack
resolveAlias does not catch it either: the vendored entry requires
./cjs/react-dom-client.production.js relatively, not through a bare specifier.

The Dockerfile now performs that same swap on the vendored entry when
HOMARR_PROFILING=true, guarded so it fails the build loudly if React's file layout
changes rather than silently producing a normal build again.

Added `pnpm docker:profiling`, which builds and then verifies, because
`docker build . -t homarr:performance` alone yields a non-profiling image and that is
almost certainly what was being run.

verify-react-profiling.mts checks the bundle rather than the runtime: 2 client chunks
carry React's profiling renderer with the flag, 0 without. It replaces a Playwright
probe that could not tell the two apart — React sends a reduced inject payload to a
synthetic devtools hook, byte-identical for both builds, so that probe reported a
false negative for profiling and production alike. The bundle marker discriminates;
confirm the Profiler tab itself with the real extension.
This commit is contained in:
Thomas Camlong committed 2026-08-09 13:39:43 +02:00
1 parent 1d09172887
commit 605431bc3f
5 files changed
+109 -6

No files matched your search

+6 -5
View File
@@ -81,15 +81,16 @@ const nextConfig: NextConfig = {
},
turbopack: {
root: path.resolve(import.meta.dirname, "../.."),
// Development runs tasks and WebSocket as separate processes. These aliases
// keep their production-only instrumentation imports out of the dev graph.
resolveAlias:
process.env.NODE_ENV === "development"
resolveAlias: {
// Development runs tasks and WebSocket as separate processes. These aliases
// keep their production-only instrumentation imports out of the dev graph.
...(process.env.NODE_ENV === "development"
? {
"@homarr/tasks": path.resolve(import.meta.dirname, "src/instrumentation-noop.ts"),
"@homarr/websocket": path.resolve(import.meta.dirname, "src/instrumentation-noop.ts"),
}
: undefined,
: {}),
},
},
transpilePackages: ["@homarr/ui", "@homarr/notifications", "@homarr/modals", "@homarr/spotlight", "@homarr/widgets"],
images: {