Repository navigation
fix(github): require() in composites breaks under ESM (#1068) - #1095
Merged
Merged
Conversation
… imports (#1068) Composites lazily required @intentius/chant/runtime to dodge a circular import that no longer exists — generated/index.ts never depends on composites/. That require() is plain CJS and breaks every example under ESM. Import Step/Job/Workflow directly from ../generated/index instead, the same classes createProperty/createResource already produced. createProperty's return type never declared that its instances satisfy Declarable, even though the constructor sets DECLARABLE_MARKER/lexicon/ entityType at runtime exactly like createResource does. That gap only surfaced once removing require()'s implicit any exposed the real type; fixed to match actual runtime behavior. Also fixes a duplicate "build" export collision in the docs-snippets example (composites-usage.ts and quickstart.ts both exported top-level build), which the example test suite had been skipping around instead of fixing, and updates the docs snippets to match. Removes the github "Every shipped example builds" entry from KNOWN_FAILURES in scripts/check-lexicons.ts now that it passes.
This was referenced Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Step/Job/Workflowused a lazyrequire("@intentius/chant/runtime")to dodge a circular import "at module load time." That cycle doesn't exist today:generated/index.tsonly imports from./runtime(a thin re-export of core), never fromcomposites/.require()is plain CJS and fails outright under ESM, which is how these modules actually run — every github example failed to build withrequire is not defined in ES module scope.createProperty/createResourcere-derivation with static imports of the already-generatedStep/Job/Workflowclasses from../generated/index(the exact same classes those calls were reconstructing).createProperty's declared return type never said its instances satisfyDeclarable, even though the constructor setsDECLARABLE_MARKER/lexicon/entityTypeat runtime exactly likecreateResourcedoes. It only worked before because every caller went through the untypedrequire(). Fixedpackages/core/src/runtime.tsto declare what was already true at runtime.require()issue also exposed a pre-existing duplicate top-levelexport const buildbetweendocs-snippets/src/composites-usage.tsanddocs-snippets/src/quickstart.ts— invisible untildocs-snippetsactually got achant build srcrun (the example test suite hadskipBuild: trueon it). Renamed tocombinedJob/buildJobrespectively, updated the matching docs snippets, and removed theskipBuildoverride.github→"Every shipped example builds"entry fromKNOWN_FAILURESinscripts/check-lexicons.tsnow that it passes. The other two github entries in that map (#1069, intrinsics export mismatch) are a separate, unrelated issue and are left untouched.Test plan
npm run build -w @intentius/chant-lexicon-githubjust buildnpx eslint packages/npx vitest run(756 passed, 1 skipped)npx tsx scripts/check-lexicons.ts— no untracked failureschant dev check-lexicon lexicons/github— "Every shipped example builds" passes (8/8)