Repository navigation
Description
Summary
@metaobjectsdev/runtime-web and @metaobjectsdev/tanstack cannot be bundled for a browser. Importing anything from either root barrel pulls in @metaobjectsdev/metadata's library/library-sources.js, which does import { fileURLToPath } from "node:url" — a Node-only API with no browser equivalent.
Since every generated <Entity>.hooks.ts imports buildFilterQs from @metaobjectsdev/runtime-web and useEntityFetcher from @metaobjectsdev/tanstack, any client consuming the generated TanStack hooks fails to build, unconditionally.
Reproduction
Two lines, no project code:
// probe.ts
import { useEntityFetcher } from "@metaobjectsdev/tanstack";
console.log(useEntityFetcher);$ bun build probe.ts --target browser
9 | import { fileURLToPath } from "node:url";
^
error: Browser polyfill for module "node:url" doesn't have a matching export named "fileURLToPath"
at node_modules/@metaobjectsdev/runtime-web/node_modules/@metaobjectsdev/metadata/dist/library/library-sources.js:9:10
Versions: @metaobjectsdev/{runtime-web,tanstack,react,codegen-ts-tanstack,codegen-ts-react}@0.21.3, @metaobjectsdev/[email protected], Bun 1.3.14.
Why this looks like an oversight rather than a design choice
@metaobjectsdev/metadata's own root barrel already guards a different Node-only module, with a comment saying exactly why:
// fixture corpora). NODE-ONLY: registry-coverage.ts statically imports node:fs
// ... not in the browser-facing barrel (it would drag node:fs into the root entry, breakingSo the hazard is recognised and handled for registry-coverage, but library/library-sources.js reaches the browser barrel through the same path. It appears to be the same class of bug, one module over.
Note also the nested install: the failing copy is at runtime-web/node_modules/@metaobjectsdev/metadata, not the hoisted one — worth checking whether a version skew between runtime-web's pinned metadata and the top-level one is part of how this slipped through.
Suggested fix
Keep library-sources (and anything else touching node:*) out of the browser-reachable barrel, the same way registry-coverage already is — or split a @metaobjectsdev/metadata/browser entry that the web packages import instead of the root.
Second issue, separable — no grid/column codegen emitted
@metaobjectsdev/codegen-ts-tanstack emits <Entity>.hooks.ts for every entity, but no <Entity>.columns.tsx or .grid.ts for any of them. Tracing it, tanstackGrid() / tanstackGridHook() appear to be opt-in behind a layout.dataGrid metadata node.
If that is intended, it is not discoverable: nothing in the metaobjects-runtime-ui skill or the package description mentions that grids require an additional metadata declaration, and the package description ("emits hooks and column definitions for TanStack Query and Table") implies columns come for free. A line in the skill, or a build-time note when an entity generates hooks but no columns, would have saved a bad assumption. Happy to file separately if you'd prefer.
Context
Reported from an adopting project generating its whole REST surface and client data layer from metadata. The generated server side (routesFileHono + runtime-ts/hono) works well now — 5/5 integration tests green against real Postgres after #286. This is the client half. As with #285/#286, we have not hand-written a substitute or patched locally; reporting instead.
Activity
fix: the two adopter blockers — sqlite apply, and browser bundling (#287
dmealing commentedon Aug 9, 2026
Fixed on
maininb145e94a— ships in the next release. Your diagnosis was exact, including theregistry-coveragecomparison: it is the same class of bug, one module over, reaching the barrel viaMetaDataLoaderinstead of directly.Fix: a new
@metaobjectsdev/metadata/constantssubpath — the fifteen pure*-constants.tsmodules with nonode:*anywhere in the graph. Browser packages import metamodel values from it; types can stay on the root, sinceimport typeis erased at build time and drags in no runtime dependency. I took this over inlining the sixLAYOUT_*strings because inlining would break the project's own constants discipline. It also givespackages/metadata/src/constants.ts— the location CLAUDE.md has always documented as the home for metamodel constants — a real existence, which it never had.Your note about the nested install was a useful steer, though the cause turned out simpler than version skew: there is exactly one value import of
metadatain all ofclient/web, and it was that one. Fixing it severs the chain for both packages.The part worth recording — your "why this slipped through" instinct was right, and the mechanism is nastier than it looks. This package's tests run under Bun's test runner, which resolves the
"bun"export condition to TypeScript source and never bundles. The failure only exists on thedistpath a published consumer resolves, under a browser-targeted bundler. So unit tests could pass forever while the package was unbuildable for its only audience. My first reproduction attempt hit exactly that trap — it took thebuncondition, built clean, and told me nothing. I had to redo it againstdistto see your error.Gated now by a real
Bun.build({ target: "browser" })over the built output, a purity check on the constants barrel, and a live demo asserting that bundling the root barrel still fails — so if the root ever becomes browser-safe, that gets noticed deliberately rather than when someone "simplifies" the import back.Verified to reproduce your error verbatim with the fix reverted:
Browser polyfill for module "node:url" doesn't have a matching export named "fileURLToPath".On the second half — grids. You're right on both counts:
tanstackGrid()/tanstackGridHook()are opt-in behind alayout.dataGridnode, and that is not discoverable. The package description does imply columns come for free. No need to file separately, it's tracked here; it's a docs/discoverability gap rather than a defect, so it isn't in this fix. Your suggestion of a build-time note when an entity generates hooks but no columns is the better half of the answer — that's the kind of thingmeta genshould say rather than leaving to a skill.Thanks again for reporting rather than patching around it. Three for three now (#285, #286, #287), and each one found a gate that couldn't see the thing it was for.
fix: grid discoverability, and gates that could not reach what they g…
chore(release): 0.21.4 coordinated (npm/PyPI/NuGet 0.21.4 · Maven 7.2…
dmealing commentedon Aug 9, 2026
Both halves fixed and released in 0.21.4.
The bundling blocker.
@metaobjectsdev/metadata's root barrel exportsMetaDataLoader→library/library-sources.ts→node:url, so the single value importruntime-webused forbuildGrid'sLAYOUT_*constants pulled the Node-only loader into every browser bundle. Fixed with a new@metaobjectsdev/metadata/constantssubpath — a barrel of pure constant modules with nonode:*anywhere in its graph. Browser packages import metamodel values from it; types still come from the root, sinceimport typeis erased at build time.Now gated by a real
Bun.build({ target: "browser" })over the builtdist/ofruntime-web,tanstack,reactandangular, plus a purity check on the constants barrel and a live demo that bundling the root barrel still fails. Nothing caught this before because these packages' tests run under Bun's test runner, which resolves thebunexport condition to TypeScript source and never bundles — so the suite could pass forever while the published package was unbuildable for its only audience.The grid half. You were right that this is separable, and right that it reads as broken codegen.
tanstackGrid()/tanstackGridHook()emit only for an entity declaring alayout.dataGrid— intended, but nothing said so, and the package description promised "hooks and column definitions" unconditionally. Rather than only fixing docs (a doc line gets missed the same way this one was), the run now tells you:It fires only when the generator emitted nothing at all, so it self-extinguishes as soon as any object declares a grid — no permanent nag on a large model.
Two things surfaced while fixing it, both also in 0.21.4:
tanstackGridHook()appeared in no example, which matters because<EntityGrid>is fully controlled (it needsrowCount, astateobject and threeonChangecallbacks) — so the documentedtanstackQuery() + tanstackGrid()pair alone left you hand-writing exactly whattanstackGridHook()generates. And a real bug: its filter was missing the TPH clause its sibling has, so a TPH subtype could get a<Sub>.grid.tswhose<Sub>.columns.tsxnever exists.Docs corrected across the package description, README,
docs/ports/typescript-client.mdand themetaobjects-runtime-uiagent skill — the old grid example omitted half of<EntityGrid>'s required props and used export names codegen does not produce.Thanks for both reports; the second one was the more useful of the two.
docs: propagate 0.21.5 / 7.21.5 across README, llms.txt, port docs an…
decide(angular): the Angular tier stays source-only — by decision (AD…
feat(cli): a `libraries` key, so a shipped library is loadable throug…
fix(codegen-ts): no generator reads an @emit* attribute any more
fix(tanstack): two cell renderers were keyed to view subtypes that do…
fix(grid): a registered view subtype with no renderer printed its raw…
docs(grid): the view.image exemption recorded the weaker of its two r…
docs(fr-029): design the metadata API + browser read-model; rule out …
docs(fr-029): implementation plan for the metadata API + browser read…
feat(runtime-web): declare the narrow MetaRead surface; widen buildGr…
feat(runtime-web): loadMetaModel — read GET /_meta into a browser rea…
test(runtime-web): cover loadMetaModel in the browser-bundling gate
test(runtime-web): cover loadMetaModel in the browser-bundling gate
test(runtime-web): cover loadMetaModel in the browser-bundling gate
test(runtime-web): restore loadMetaModel browser-bundle coverage
feat(cli): add meta schema command and retire ai-runtime publish (#639)