Files
chat/client/babel.config.cjs
zooqueen ad15a7025e Lift the @hanzo/ui version ceiling: 8.0.48 -> 8.0.63
The ceiling was documented as a jsdom limitation — its CSS parser could not
read modern slash-alpha, so every 8.x primitive threw "Missing theme.".
Measured: jsdom 26.1.0 parses `rgb(255 255 255 / .10)` fine. The note was
wrong, and it had pinned this app three minor versions behind the fleet and
kept @hanzo/ui/product unimportable, so every switcher, panel and settings
surface here is hand-rolled instead of shared.

Two real causes, both invisible from the error text.

One: babel applies a ROOT config only to files under its root, and every
Hanzo package resolves to chat/node_modules — a level ABOVE client/. So
babel-jest transformed them with NO config, the transform-import-meta plugin
listed right there never ran, and @hanzogui/telemetry died on `Cannot use
'import.meta' outside a module`. Naming the config in the jest transform
fixes that; the plugins still left `import.meta` standing, because both
rewrite `import.meta.url` and `import.meta.env` while that package ships
`import.meta?.env` — an optional member expression neither matches. Handled
at the MetaProperty node itself, so what is chained onto it stops mattering.

Two: the bump split @hanzogui/web across FOUR versions in one tree — 26
packages on 8.0.0, 9 on 8.0.1, 90 on 8.1.1 — leaving 17 copies installed,
sixteen of them nested. React context is per module instance, so the theme a
provider publishes from one copy is invisible to a Switch reading it from
another, and that is the real "Missing theme.": not a parser, a duplicate.
One pnpm override collapses 17 copies to 1.

Verified against a measured pre-bump baseline, which the ceiling note never
was: 80 failed / 131 passed suites and 534 failed / 1979 passed tests before,
identical after, and the failing-suite SET diffs empty in both directions.
Those 534 are pre-existing and untouched here. guiPrimitives passes 4/4 and
@hanzo/ui/product now imports 145 components.
2026-08-06 05:06:59 -07:00

52 lines
1.6 KiB
JavaScript

/**
* `import.meta` is illegal in the CJS modules jest builds, and the two plugins
* below only rewrite the shapes they were written for — `import.meta.url` and
* `import.meta.env`. Hanzo packages ship `import.meta?.env`, an OPTIONAL member
* expression, which both skip. One unrewritten occurrence in
* `@hanzogui/telemetry/dist/esm/env.mjs` is the whole reason `@hanzo/ui/product`
* could not be imported here and this app sat three minors behind the fleet.
*
* This handles the node itself (`MetaProperty`), so it does not care what is
* chained onto it. Tests get an empty env, which is what they want: the real
* values come from Vite at build time and telemetry must not phone home from a
* unit test.
*/
const transformImportMetaNode = () => ({
name: 'hanzo-transform-import-meta-node',
visitor: {
MetaProperty(path) {
path.replaceWithSourceString("({ env: {}, url: 'file:///' })");
},
},
});
/*
babel is used for frontend unit testing
*/
module.exports = {
presets: [
['@babel/preset-env', { 'targets': { 'node': 'current' } }], //compiling ES2015+ syntax
['@babel/preset-react', { runtime: 'automatic' }],
'@babel/preset-typescript',
],
/*
Babel's code transformations are enabled by applying plugins (or presets) to your configuration file.
*/
plugins: [
'@babel/plugin-transform-runtime',
transformImportMetaNode,
'babel-plugin-transform-import-meta',
'babel-plugin-transform-vite-meta-env',
'babel-plugin-replace-ts-export-assignment',
[
'babel-plugin-root-import',
{
'rootPathPrefix': '~/',
'rootPathSuffix': './src',
},
],
],
};