Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit af5e292

Browse files
fix(react): make the published entry loadable by Node's own ESM resolver, and gate it (#5218)
* fix(react,types,core,i18n): explicit extensions so plain Node ESM can load the built entry `packages/react/dist/index.js` re-exported through extensionless relative specifiers (`./SchemaRenderer`, `./hooks`, ...). Node's ESM resolver does not extension-search relative specifiers, so importing the published entry under plain Node failed with ERR_MODULE_NOT_FOUND. `tsc` never rewrites import specifiers, so the defect is in the source, not in a build setting: the root tsconfig's `moduleResolution: "bundler"` permits the extensionless form and bare `tsc` copies it straight into dist. - packages/react: 92 specifiers extensioned; tsconfig pinned to module/moduleResolution `nodenext` so a missing extension is a compile error (TS2835) rather than a review item. - packages/types, core, i18n: 163 specifiers extensioned. These are react's dependency closure — react's own entry stayed unloadable until they were fixed too, because evaluation crosses into them. * test(scripts): gate that published ESM packages load under plain Node Two legs, because neither is honest alone (objectui#4538): - `pnpm check:esm-specifiers` reads SOURCES and needs no build, so it runs per pull request in ci.yml's Type Check job. For a package whose build preserves specifiers (a bare emitting `tsc`), the emitted specifier IS the source specifier, so the defect is judgeable without building anything. - `pnpm check:node-esm-load` builds every published package and actually `import()`s each entry in a child node. Wired to a nightly workflow, not to pull requests, for the reason published-dist-gate.yml records: this repo has no per-PR full-repo build. The load leg EVALUATES rather than resolves, which is the card's measured point: plugin-charts' own entry resolves fine and the tree was still broken. A missing module is attributed to the package that OWNS it, so the four plugins failing on packages/mobile/dist/useBreakpoint produce one finding against @object-ui/mobile rather than four against innocent importers. Seven packages still carry the defect and are ledgered with a reason each; two of them were held by other sessions. The ledger is a ratchet — an entry whose package is now clean is itself a failure. * chore(scripts): point the SPECIFIER_DEBT ledger at objectui#5214 Each entry now names the card that clears it, and the three that block other packages say how many — mobile blocks 6, permissions 4, providers 2. A ledger entry whose reason is just "follow-up" tells the next reader nothing about whether it is worth picking up. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d2ce342 commit af5e292

69 files changed

Lines changed: 1298 additions & 257 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.changeset/gentle-pears-invent.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@object-ui/react': patch
3+
'@object-ui/types': patch
4+
'@object-ui/core': patch
5+
'@object-ui/i18n': patch
6+
---
7+
8+
Emit explicit file extensions on relative import specifiers, so the published
9+
entries can be imported by Node's own ESM resolver.
10+
11+
`@object-ui/react`'s built entry re-exported through extensionless relative
12+
specifiers (`export * from './SchemaRenderer'`). Node does not extension-search
13+
relative specifiers, so `import('@object-ui/react')` under plain Node — an SSR
14+
host, or any consumer without a bundler — failed with `ERR_MODULE_NOT_FOUND`.
15+
Bundled consumers were never affected and are unchanged by this.
16+
17+
`@object-ui/types`, `@object-ui/core` and `@object-ui/i18n` carried the same
18+
emission; `@object-ui/react`'s entry stayed unloadable until they were fixed
19+
too, because evaluation crosses into them. No exported API changed.

‎.github/workflows/ci.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,24 @@ jobs:
210210
if: steps.relevant.outputs.should_run == 'true'
211211
run: pnpm check:self-import
212212

213+
# Node's ESM resolver does not extension-search relative specifiers, so an
214+
# extensionless `./SchemaRenderer` in a published `dist/` is unloadable
215+
# under plain Node — `@object-ui/react`'s entry died with
216+
# ERR_MODULE_NOT_FOUND (objectui#4538). `tsc` never rewrites specifiers, so
217+
# for a package whose build preserves them the SOURCE specifier is the
218+
# emitted one, and the defect can be judged without building anything.
219+
# That is why the cheap leg runs here: it reads sources, needs only the
220+
# install, and catches a regression the moment it is written.
221+
#
222+
# The expensive leg — which BUILDS and actually imports each published
223+
# entry — is `.github/workflows/node-esm-load-gate.yml`. It is not here on
224+
# purpose: it needs a full-repo build, which this repository deliberately
225+
# does not do per pull request (the same trade `published-dist-gate.yml`
226+
# records at length).
227+
- name: Verify published ESM packages emit resolvable relative specifiers
228+
if: steps.relevant.outputs.should_run == 'true'
229+
run: pnpm check:esm-specifiers
230+
213231
# A local type/const declared under a `@objectstack/spec` export's NAME reads
214232
# to the next agent as the spec's own definition — four such symbols had
215233
# already drifted from the spec they claimed to be (objectstack#4115). Needs
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Node ESM Load Gate
2+
3+
# The artifact-level half of objectui#4538: every published ESM package must be
4+
# importable by Node's own resolver, with no bundler and no loader hooks. The
5+
# gate, and why a resolution-only criterion was measured and rejected, are
6+
# documented at length in scripts/check-node-esm-load.mjs.
7+
#
8+
# ── Why this is a scheduled workflow and NOT a pull-request job ──────────────
9+
#
10+
# The load leg has to EVALUATE each entry, so it has to build all 39 published
11+
# packages. This repository deliberately has no per-PR full-repo build —
12+
# `ci.yml`'s `Build & E2E` builds `@object-ui/console` alone, and its `Type
13+
# Check` gets only the DEPENDENCY CLOSURE out of turbo's `dependsOn:
14+
# ["^build"]`, so leaf packages such as `@object-ui/plugin-map` are never built
15+
# there. `published-dist-gate.yml` records the same trade for the same reason,
16+
# and the 2026-08-16 ruling on objectui#4846 rejected paying a full build per
17+
# pull request to catch a defect that reaches a user at publish time.
18+
#
19+
# ⛔ Do not add `pull_request` here. The per-PR half of objectui#4538 is the
20+
# CHEAP leg — `pnpm check:esm-specifiers`, a source-level scan that needs no
21+
# build — and it already runs in `ci.yml`'s `Type Check` job. That leg is the
22+
# ratchet; this workflow is the proof that the ratchet guards the right
23+
# property, because it is the only thing that can catch a package broken by a
24+
# DEPENDENCY rather than by its own sources (measured: four plugin packages
25+
# failing on `packages/mobile/dist/useBreakpoint`, which is not their file).
26+
#
27+
# This workflow is therefore an ALARM, not a merge blocker: it cannot make
28+
# anyone's pull request red, so a slow run costs a second look and nothing else.
29+
30+
on:
31+
workflow_dispatch:
32+
33+
# Nightly at 04:17 UTC — after `published-dist-gate.yml`'s 03:41 so the two
34+
# full builds do not contend, and off the top of the hour because GitHub's
35+
# scheduled queue is most congested, and most delayed, at :00.
36+
schedule:
37+
- cron: '17 4 * * *'
38+
39+
# Changes to the gate itself get a real run. Its unit tests DO run per-PR
40+
# inside the ordinary vitest suite, but they exercise the verdicts over
41+
# synthetic fixtures and cannot exercise a real build.
42+
push:
43+
branches: [main]
44+
paths:
45+
- 'scripts/check-node-esm-load.mjs'
46+
- '.github/workflows/node-esm-load-gate.yml'
47+
48+
concurrency:
49+
group: node-esm-load-gate-${{ github.ref }}
50+
cancel-in-progress: true
51+
52+
permissions:
53+
contents: read
54+
55+
jobs:
56+
node-esm-load:
57+
name: Node ESM Load Scan
58+
runs-on: ubuntu-latest
59+
# A full build of every published package plus one child `node` import per
60+
# package. Generous, because a timeout here reads as a gate failure and this
61+
# workflow blocks nobody.
62+
timeout-minutes: 60
63+
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v7
67+
with:
68+
submodules: true
69+
70+
- name: Enable Corepack
71+
run: corepack enable
72+
73+
- name: Setup Node.js
74+
uses: actions/setup-node@v7
75+
with:
76+
node-version: '22.x'
77+
cache: 'pnpm'
78+
79+
- name: Install dependencies
80+
run: pnpm install --frozen-lockfile
81+
82+
# No `pnpm build` step before this one, on purpose. The gate runs the build
83+
# ITSELF and fails when it cannot, so that "there were no artifacts,
84+
# therefore nothing was wrong" can never be this workflow's verdict. A
85+
# published package whose entry is missing after the build is reported as
86+
# `no-build-output`, not skipped, and the run asserts a floor on how many
87+
# entries actually evaluated.
88+
- name: Build every published package and import its entry under plain Node
89+
run: pnpm check:node-esm-load

‎content/docs/guide/ci-cd-pipeline.md‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ one has its own section below.
4444
| `shadcn-check.yml` | Check Shadcn Components | Weekly cron `0 9 * * 1`; manual | n/a |
4545
| `check-links.yml` | Check Links | Weekly cron `17 4 * * 0`; manual | n/a — reports, never gates |
4646
| `published-dist-gate.yml` | Published Dist Tooling Scan | Nightly cron `41 3 * * *`; push to `main` touching the gate; manual | No — the blocking copy runs on the publish path, not here |
47+
| `node-esm-load-gate.yml` | Node ESM Load Scan | Nightly cron `17 4 * * *`; push to `main` touching the gate; manual | No — the per-PR half is `pnpm check:esm-specifiers` in **Type Check** |
4748

4849
The path filters explain most "why did nothing run on my PR?" questions:
4950

@@ -172,7 +173,7 @@ it green — which is how two of `type-check`'s gates came to be missing from th
172173
| Job key | Appears as | What it runs | When |
173174
|---|---|---|---|
174175
| `changeset-check` | Changeset Fixed Group Check | `scripts/check-changeset-fixed.mjs` — every workspace package must be in the changeset `fixed` group or explicitly ignored. It checks group *membership*; it does **not** check whether the PR added a changeset. | Every run |
175-
| `type-check` | Type Check | `scripts/check-type-check-coverage.mjs`, then `pnpm check:phantom-deps`, then `pnpm check:self-import`, then `pnpm check:spec-symbols`, then `pnpm check:action-forward-parity`, then `pnpm check:i18n-keys`, then `pnpm check:i18n-drift`, then `pnpm type-check:scripts`, then `pnpm type-check`, then `pnpm type-check:vitest-setup`. The coverage guard runs first because turbo silently skips packages that have no `type-check` script, so a package without one would otherwise read as passing (#2911). `pnpm check:phantom-deps` fails when a released package imports a bare specifier its own `package.json` does not declare — a *phantom dependency*, invisible locally because the workspace root's `devDependencies` sit on the upward resolution path from every package directory and on no consumer's, so `require.resolve('react', { paths: ['packages/core/src'] })` succeeds while `@object-ui/core` declares react in no field at all ([#4394](https://github.com/objectstack-ai/objectui/issues/4394)). `pnpm check:self-import` runs next because it reuses that gate's parser: it fails when a file inside a package names its OWN package, a specifier that resolves through the package's `exports` map to `dist/` while `type-check` waits on `^build` — the *dependencies'* builds, never the package's own — so on a cold cache the declarations do not exist yet and the file fails with `TS2307`. Locally it is always green, because every local workflow builds before it type-checks and leaves a `dist/` behind; PR #4789's first run was red on exactly one such line ([#4801](https://github.com/objectstack-ai/objectui/issues/4801)). `pnpm check:action-forward-parity` fails when an action renderer's forward whitelist drops a key the action runtime reads — the class that shipped six times one key at a time, each time green, because the key parses and publishes while the payload is dropped one hop before the runner ([#4050](https://github.com/objectstack-ai/objectui/issues/4050)). The two locale gates sit in the middle because both parse the sources with `typescript`: they need the install and nothing built. `pnpm check:i18n-keys` fails when a `t()` call site asks for a key the `en` pack does not define ([#3530](https://github.com/objectstack-ai/objectui/issues/3530)); `pnpm check:i18n-drift` fails when a change to an `en` string is not accompanied by the nine translation packs ([#3650](https://github.com/objectstack-ai/objectui/issues/3650)), and it is why this job's checkout sets `fetch-depth: 0` — it diffs against the merge base, which a depth-1 clone cannot resolve. `pnpm type-check:scripts` (`tsconfig.scripts.json`) covers `scripts/**/*.ts`, which `pnpm type-check` cannot reach at all — `scripts/` has no package.json, so turbo never walks it, and the coverage guard decides coverage per *package*. Until [#3494](https://github.com/objectstack-ai/objectui/issues/3494) that left the pin tests in `scripts/__tests__/` — including the one pinning this very page — compiled by nothing. `pnpm type-check:vitest-setup` (`tsconfig.vitest-setup.json`) closes the same gap for the four repo-root `vitest.setup.*` files, uncovered until [#3515](https://github.com/objectstack-ai/objectui/issues/3515); it runs *last*, after `pnpm type-check`, because `vitest.setup.dom.tsx` side-effect-imports four `@object-ui/*` packages and resolves them through the declarations that turbo's `^build` produces. | Every run; on a PR the steps short-circuit when only ignored paths changed |
176+
| `type-check` | Type Check | `scripts/check-type-check-coverage.mjs`, then `pnpm check:phantom-deps`, then `pnpm check:self-import`, then `pnpm check:esm-specifiers`, then `pnpm check:spec-symbols`, then `pnpm check:action-forward-parity`, then `pnpm check:i18n-keys`, then `pnpm check:i18n-drift`, then `pnpm type-check:scripts`, then `pnpm type-check`, then `pnpm type-check:vitest-setup`. The coverage guard runs first because turbo silently skips packages that have no `type-check` script, so a package without one would otherwise read as passing (#2911). `pnpm check:phantom-deps` fails when a released package imports a bare specifier its own `package.json` does not declare — a *phantom dependency*, invisible locally because the workspace root's `devDependencies` sit on the upward resolution path from every package directory and on no consumer's, so `require.resolve('react', { paths: ['packages/core/src'] })` succeeds while `@object-ui/core` declares react in no field at all ([#4394](https://github.com/objectstack-ai/objectui/issues/4394)). `pnpm check:self-import` runs next because it reuses that gate's parser: it fails when a file inside a package names its OWN package, a specifier that resolves through the package's `exports` map to `dist/` while `type-check` waits on `^build` — the *dependencies'* builds, never the package's own — so on a cold cache the declarations do not exist yet and the file fails with `TS2307`. Locally it is always green, because every local workflow builds before it type-checks and leaves a `dist/` behind; PR #4789's first run was red on exactly one such line ([#4801](https://github.com/objectstack-ai/objectui/issues/4801)). `pnpm check:esm-specifiers` follows it for the same reason — sources only, no build: it fails when a published package whose build preserves import specifiers (a bare emitting `tsc`, which never rewrites them) writes a relative specifier with no file extension. Node's ESM resolver does not extension-search relative specifiers, so such a specifier makes the published entry unloadable outside a bundler; `@object-ui/react`'s entry died with `ERR_MODULE_NOT_FOUND` while every bundler-based consumer, the whole test suite and CI stayed green ([#4538](https://github.com/objectstack-ai/objectui/issues/4538)). The half that actually *imports* each built entry needs a full build and runs in `node-esm-load-gate.yml`. `pnpm check:action-forward-parity` fails when an action renderer's forward whitelist drops a key the action runtime reads — the class that shipped six times one key at a time, each time green, because the key parses and publishes while the payload is dropped one hop before the runner ([#4050](https://github.com/objectstack-ai/objectui/issues/4050)). The two locale gates sit in the middle because both parse the sources with `typescript`: they need the install and nothing built. `pnpm check:i18n-keys` fails when a `t()` call site asks for a key the `en` pack does not define ([#3530](https://github.com/objectstack-ai/objectui/issues/3530)); `pnpm check:i18n-drift` fails when a change to an `en` string is not accompanied by the nine translation packs ([#3650](https://github.com/objectstack-ai/objectui/issues/3650)), and it is why this job's checkout sets `fetch-depth: 0` — it diffs against the merge base, which a depth-1 clone cannot resolve. `pnpm type-check:scripts` (`tsconfig.scripts.json`) covers `scripts/**/*.ts`, which `pnpm type-check` cannot reach at all — `scripts/` has no package.json, so turbo never walks it, and the coverage guard decides coverage per *package*. Until [#3494](https://github.com/objectstack-ai/objectui/issues/3494) that left the pin tests in `scripts/__tests__/` — including the one pinning this very page — compiled by nothing. `pnpm type-check:vitest-setup` (`tsconfig.vitest-setup.json`) closes the same gap for the four repo-root `vitest.setup.*` files, uncovered until [#3515](https://github.com/objectstack-ai/objectui/issues/3515); it runs *last*, after `pnpm type-check`, because `vitest.setup.dom.tsx` side-effect-imports four `@object-ui/*` packages and resolves them through the declarations that turbo's `^build` produces. | Every run; on a PR the steps short-circuit when only ignored paths changed |
176177
| `test` | Test (shard N/4) | `pnpm test --shard=N/4` across a 4-runner matrix with `fail-fast: false`, so every shard reports its own failures. No coverage instrumentation — v8 adds 40–100% overhead. | Pull requests and merge-queue builds (everything but `push`); steps short-circuit on a PR that changed only ignored paths |
177178
| `test-coverage` | Test (coverage) | One unsharded `pnpm test:coverage`, uploaded to Codecov. Nothing blocks on it, which is why it is not sharded. | **Push only** |
178179
| `e2e` | Build & E2E | Builds the console with `vite build` (`VITE_BASE_PATH=/console/`), verifies the artifact, then `pnpm test:e2e --project=chromium`. Uploads the Playwright report on failure. | Every run; on a PR the steps short-circuit when only ignored paths changed |
@@ -744,6 +745,44 @@ Three things about it are easy to get wrong and are written down in the script's
744745
Check** gets only the dependency closure from turbo's `dependsOn: ["^build"]`, so leaf packages
745746
are never built there. The blocking copy runs on the publish path instead — see below.
746747

748+
### Node ESM Load Gate (`node-esm-load-gate.yml`)
749+
750+
**Trigger:** Nightly cron `17 4 * * *`; push to `main` that touches the gate script or this
751+
workflow; manual. **It carries no `pull_request` trigger, on purpose.**
752+
753+
Every published ESM package must be importable by Node's own resolver — no bundler, no loader
754+
hooks. The gate is `scripts/check-node-esm-load.mjs` and it has two legs, only one of which runs
755+
here:
756+
757+
- **The specifier leg** (`pnpm check:esm-specifiers`) reads *sources* and needs no build, so it
758+
runs per pull request in **Type Check**, not in this workflow. It is the ratchet: for a package
759+
whose build preserves import specifiers, the emitted specifier *is* the source specifier,
760+
because `tsc` never rewrites them.
761+
- **The load leg** (`pnpm check:node-esm-load`) builds every published package and then actually
762+
`import()`s each entry in a child `node`. That is what runs here, and it needs the full build
763+
this repository has no per-PR copy of — the same trade `published-dist-gate.yml` records above.
764+
765+
Both legs exist because neither is honest alone
766+
([#4538](https://github.com/objectstack-ai/objectui/issues/4538)):
767+
768+
- **Resolving the entry is not enough.** The card was filed from `@object-ui/plugin-charts`,
769+
whose own emitted entry resolves perfectly; the failure appeared only once evaluation crossed
770+
into `@object-ui/react`. A check that stops at resolution passes while the tree is broken, so
771+
the load leg evaluates.
772+
- **The specifier leg cannot see a defect that arrives through a dependency.** In the first full
773+
run, four plugin packages failed on `packages/mobile/dist/useBreakpoint` — not their file. The
774+
gate therefore attributes a missing module to the package that *owns* it, so one cause produces
775+
one finding against one owner.
776+
- **It must never pass vacuously.** "Imported nothing, found nothing" is the verdict this gate may
777+
never give, so both legs assert a floor on how much they inspected, and a published entry that
778+
is missing after the build is a finding (`no-build-output`), not a skip.
779+
780+
Packages that still carry the defect are named in the script's `SPECIFIER_DEBT` ledger with a
781+
reason each. The ledger is a ratchet, not a mute button: an entry whose package has become clean
782+
is itself a failure, so it cannot outlive the debt it records. Packages that are not importable
783+
by design — a `bin`-only CLI, or a built web app whose `dist` is `index.html` — are printed on
784+
every run rather than skipped silently.
785+
747786
### Changeset Guard (`changeset-guard.yml`)
748787

749788
**Trigger:** PR to `main`/`develop`, and push to `main`, **when `.changeset/**` changes** — the

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"check:action-forward-parity": "node scripts/check-action-forward-parity.mjs",
4242
"check:phantom-deps": "node scripts/check-phantom-dependencies.mjs",
4343
"check:self-import": "node scripts/check-package-self-import.mjs",
44+
"check:esm-specifiers": "node scripts/check-node-esm-load.mjs --specifiers-only",
45+
"check:node-esm-load": "node scripts/check-node-esm-load.mjs",
4446
"check:control-bytes": "node scripts/check-control-bytes.mjs",
4547
"check:published-dist": "node scripts/check-published-dist-tooling.mjs",
4648
"check:i18n-keys": "node scripts/check-i18n-call-site-keys.mjs",

‎packages/core/src/actions/ActionEngine.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* ActionSchema[] → ActionEngine → ActionRunner → ActionResult
1717
*/
1818

19-
import { ActionRunner, type ActionDef, type ActionContext, type ActionResult } from './ActionRunner';
19+
import { ActionRunner, type ActionDef, type ActionContext, type ActionResult } from './ActionRunner.js';
2020
import { toPredicateInput } from '../evaluator/predicateInput.js';
2121
import { hasDeclaredPredicate } from '../evaluator/declaredPredicate.js';
2222

0 commit comments

Comments
 (0)