Repository navigation
Description
Found while implementing #1067's "every shipped example builds" check against every lexicon (not just aws).
The defect
chant dev check-lexicon lexicons/github — and plain chant build lexicons/github/examples/<any>/src — fails on every one of github's 8 examples:
$ npx tsx packages/core/src/cli/main.ts build lexicons/github/examples/getting-started/src
error: require is not defined in ES module scope, you can use import instead
Root cause: several github composites use a lazy require() to avoid a circular import at module-load time, e.g. lexicons/github/src/composites/checkout.ts:
// Import Step lazily to avoid circular dependency at module load time
const { createProperty } = require("@intentius/chant/runtime");Same pattern in cache.ts, deploy-environment.ts, go-ci.ts, python-ci.ts, download-artifact.ts, setup-go.ts, docker-build.ts, upload-artifact.ts, node-pipeline.ts, node-ci.ts, setup-node.ts, setup-python.ts (13 files total). require is not defined in an ESM module — this is fundamentally incompatible with how these files actually run (confirmed: fails via the plain CLI, not just the new check-lexicon example-build audit).
Why this wasn't caught before
chant dev check-lexicon never ran in CI (that's #1067's core finding), and nothing else in CI builds a github example directly — the "Build example project" CI step only exercises lexicons/aws/examples/lambda-function.
Scope
Whoever picks this up needs to understand why the lazy require was introduced (the comment says "to avoid circular dependency at module load time") before converting it to a top-level import — naively hoisting the import could reintroduce the exact cycle the workaround was solving. Options to investigate:
- Whether the circular dependency is still real today (generated code has likely changed since this was written).
- Whether discovery's run-fallback execution path could/should provide a
requireshim (unlikely to be the right fix, but worth ruling out). - A restructuring that breaks the cycle properly (e.g. a lazy-init pattern that doesn't rely on CJS
require).
Acceptance
- All 8 github examples (
deploy-pages,docker-build,docs-snippets,getting-started,matrix-test,node-ci,release-please,reusable-workflow) build cleanly viachant build lexicons/github/examples/<name>/src. -
chant dev check-lexicon lexicons/github's "Every shipped example builds" check passes. - The
githubentry can be removed fromKNOWN_FAILURESinscripts/check-lexicons.ts.
Activity
feat(core): lexicon contract must validate intrinsic foldability — an…
fix(github): replace ESM-incompatible require() with static generated…
lex00 commentedon Jul 27, 2026
Fixed in PR #1095 — composites now import the generated Step/Job classes directly as ESM (the lazy require() existed to dodge a module-load cycle that no longer exists), createProperty's return type carries Declarable, colliding docs-snippet exports renamed, and the KNOWN_FAILURES entry removed so the contract gates it.