Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/26126-console-version-define-test-leak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@object-ui/console': patch
---

fix(console): the console's build-identity define no longer leaks into the other ui test projects

Clause-②: no (build/test configuration only; no exported type or runtime contract change; the console production build keeps its version stamp)
Metadata-protocol: none

The console's Vite config bakes `import.meta.env.VITE_APP_VERSION` (the build's version, else the git short sha) as a `define`. The console's vitest project merges that config, and vitest moves every `import.meta.env.*` / `process.env.*` define into the main process's `process.env` while it resolves a project's config, so every other ui test project's workers inherited the console's git sha. App-shell's `getConsoleBuild()` then read that sha instead of `null`, and `buildIdentity-12970`'s "reads null" case went red in full ui runs. The console's vitest config now drops those keys from the merged Vite config. `vite build` still bakes the version exactly as before.
17 changes: 16 additions & 1 deletion ui/apps/console/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,23 @@ import rootConfig from '../../vitest.config.mts';
// (objectui#3384).
import viteConfig from './vite.config.ts';

// The console BUILD bakes its identity as a `define` on
// `import.meta.env.VITE_APP_VERSION` (objectui#12970) — and vitest does not
// scope such a define to the project that declares it. While it resolves a
// project's config it moves every `import.meta.env.*` / `process.env.*` define
// into the main process's `process.env` (`deleteDefineConfig` in vitest's
// cli-api chunk), which the workers of EVERY project inherit. So the console's
// git sha surfaced in app-shell's `getConsoleBuild()` and turned
// `buildIdentity-12970`'s "reads null" case red in full runs, depending on
// shard layout (#26126). Those defines stay in the build and stop here; no
// console test reads them.
const LEAKS_INTO_PROCESS_ENV = /^(import\.meta\.env|process\.env)\./;
const testDefine = Object.fromEntries(
Object.entries(viteConfig.define ?? {}).filter(([key]) => !LEAKS_INTO_PROCESS_ENV.test(key))
);

export default mergeConfig(
mergeConfig(rootConfig, viteConfig),
mergeConfig(rootConfig, { ...viteConfig, define: testDefine }),
defineConfig({
test: {
// The root config no longer sets global setupFiles (they moved into the
Expand Down
Loading