Files
site-builder/craft/src/main.tsx
T
shadowdaoandClaude Opus 5 4cfcccd272 fix(site-builder): swap build-stamp console.log for a window global, add test
Review found two real issues in the initial build-stamp commit:

- A permanent, unconditional console.log on every editor load for every
  customer is production noise. Replaced with a window.__WHP_EDITOR_BUILD__
  assignment -- same load-bearing effect (keeps build-stamp.ts from being
  tree-shaken out before Task 19 wires in the real call site), but prints
  nothing. Support can ask a user to type __WHP_EDITOR_BUILD__ in the
  console on request. Commented as load-bearing so it isn't later "cleaned
  up" as a stray global.
- editorBuild()'s 'dev' fallback was never actually exercised by any test
  in the suite, despite the previous report claiming otherwise. Added
  build-stamp.test.ts asserting editorBuild() === 'dev' under vitest.

Also silences the expected-failure stderr git prints on the successful
'nogit' fallback path (stdio: ['ignore', 'pipe', 'ignore']), so a
release-tarball build log doesn't show a misleading fatal: line for an
intentional, handled case.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-09 11:05:01 -07:00

31 lines
1.3 KiB
TypeScript

import React from 'react';
import ReactDOM from 'react-dom/client';
import { App } from './App';
import { WhpConfig } from './types';
import { installConsoleErrorBuffer } from './utils/console-buffer';
import { editorBuild } from './utils/build-stamp';
import './styles/editor.css';
// Installed before React mounts so errors thrown during the first render are
// captured too.
installConsoleErrorBuffer();
// Exposed on window (not logged -- no need to print this on every load for
// every customer) so support can ask someone to type __WHP_EDITOR_BUILD__
// in the console on request. This call is also load-bearing for bundling:
// it is currently the only reference to `editorBuild()`, which keeps the
// __EDITOR_BUILD__-reading module from being tree-shaken out of the bundle
// before Task 19 wires it into the report payload. Do not remove this line
// as a "stray global" cleanup -- doing so silently reverts every future
// bug report to showing 'dev' instead of a real build stamp.
(window as any).__WHP_EDITOR_BUILD__ = editorBuild();
// Read WHP_CONFIG injected by PHP wrapper (or null for standalone dev)
const whpConfig: WhpConfig | null = (window as any).WHP_CONFIG || null;
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App whpConfig={whpConfig} />
</React.StrictMode>
);