Skip to content

feat(module): generate CLI 1.0 modules in the SDK - #27

Closed
TomChv wants to merge 1 commit into
feat/module-gen-dangfrom
feat/module-gen-cutover
Closed

TomChv wants to merge 1 commit into
feat/module-gen-dangfrom
feat/module-gen-cutover

Conversation

@TomChv

@TomChv TomChv commented Aug 11, 2026

Copy link
Copy Markdown
Member

Mod.generate now generates dagger-module.toml modules here instead of routing
through the engine's built-in TypeScript runtime. dagger.json modules keep
delegating: that runtime regenerates everything at call time regardless, so
generating them here would only leave a second, differently-versioned copy of
the same files on disk.

Dependency-closure staging is kept for both paths — a dependent's schema can
only be loaded once its local deps' generated files exist, which is true no
matter who does the generating.

No .gitignore or .gitattributes is written. The engine appends to both around
codegen, but for a workspace module the ignore list reduces to
node_modules/.pnpm-store, which is the user's business rather than codegen's.

The new check asserts the tree contract rather than one marker file, because
that contract is enforced somewhere else entirely: the runtime does no codegen
for these modules, so a missing piece surfaces as a module that won't load at
dagger call time, long after generate ran.

Signed-off-by: Tom Chauveau [email protected]


Stack created with GitHub Stacks CLI • Give Feedback 💬

@TomChv
TomChv force-pushed the feat/module-gen-cutover branch from 60ab175 to 5bb27c6 Compare August 19, 2026 14:53
@TomChv
TomChv force-pushed the feat/module-gen-cutover branch from 5bb27c6 to 2d94993 Compare August 21, 2026 12:11
@TomChv
TomChv force-pushed the feat/module-gen-cutover branch from 2d94993 to 170c5d5 Compare August 25, 2026 16:06
@TomChv
TomChv marked this pull request as ready for review August 25, 2026 16:15
@TomChv
TomChv force-pushed the feat/module-gen-cutover branch from 170c5d5 to 68a16a1 Compare August 28, 2026 11:24
@TomChv
TomChv force-pushed the feat/module-gen-cutover branch from 68a16a1 to 5129f66 Compare August 28, 2026 12:26
Route Mod.generate to this SDK's generator for dagger-module.toml modules, and
keep delegating to the engine for dagger.json ones. A workspace module builds
from its committed files, so what generate writes *is* what the runtime
executes; a legacy module regenerates at call time anyway, and generating it
here would only leave a second, differently-versioned copy on disk. Both routes
run through generateStaged so `mod generate` and generate-all cannot pick
different generators.

Both keep the generateLocalDependencies staging: a dependent's schema is only
loadable once its local deps' generated files exist, and dep generation may
cross SDKs.

That staging is scaffolding, not output, and each route has to take it back out
a different way. The SDK route builds its changeset out of the unstaged
workspace, so the deps never enter it. The engine route hands back a whole
workspace instead, so this takes the module's own directory out of that result
and lays it over the unstaged base — diffing the whole thing against the base
would write the dependencies' generated files into the user's tree alongside
the module they asked for, and diffing against the staged workspace instead
cancels the module's own output whenever the engine has already generated it
for a dependent. generate-legacy-deps covers the case; generate-deps already
covered the SDK side.

Staging the generated tree over the module's existing one, rather than in place
of it, is what keeps the module's source and config out of the changeset —
withNewDirectory swaps the whole directory, and staging only what we generate
reports everything else as deleted. Applying to disk hides that; staging into a
workspace does not, and the engine generates a dependency by doing exactly that.

The cost of layering is that a file we stop generating is left behind, so
regeneration prunes the `*.gen.ts` it owns first. Without it a dependency
dropped from a module's config keeps its <dep>.gen.ts, exporting an API against
a module that is no longer served, and a default tsc rejects the directory.
Pruned in both the baseline and the workspace, for the same reason client
generation does both.

The typescript pin gets a check that can fail. Asserting it on a fixture that
arrives pinned only proves generation left it alone, so the dependency fixture
drops to a bare package.json — the shape a module has before its first generate
— and the check asserts the pin appears.

Signed-off-by: Tom Chauveau <[email protected]>
@TomChv

TomChv commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

Superseded by #39, which squashes this whole stack into a single PR off main (same tree, byte for byte).

The stack had PRs overwriting each other — this one included — which made the intermediate states hard to reason about, and thirteen PRs each fanning out a full check suite made CI unreadable. Branch is left pushed, so nothing here is lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants