Skip to content

feat(config-updator): pin typescript in module config - #25

Closed
TomChv wants to merge 1 commit into
feat/codegen-entrypoint-modefrom
feat/module-config-writers
Closed

TomChv wants to merge 1 commit into
feat/codegen-entrypoint-modefrom
feat/module-config-writers

Conversation

@TomChv

@TomChv TomChv commented Aug 11, 2026

Copy link
Copy Markdown
Member

Module codegen needs the same package.json/tsconfig/deno.json writers init
already has — they were the module writers all along, just missing the one
thing codegen adds: the typescript pin.

It is not cosmetic. The runtime mounts its own prebuilt compiler, and skips
dependency installation entirely for an otherwise dependency-free module, only
when the pin matches the engine's default; without it every dagger call pays
for a package-manager install. Deno has no node_modules to fall back on, so it
gets the same pin through its import map.

Both use setIfNotExists, so a module that picked its own version keeps it and
accepts the install rather than being silently retargeted. Existing
expectations updated for the new output, with explicit cases for the
preservation path.

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


Stack created with GitHub Stacks CLI • Give Feedback 💬

@TomChv
TomChv force-pushed the feat/module-config-writers branch from 1de881b to ce593e0 Compare August 21, 2026 12:11
@TomChv
TomChv force-pushed the feat/module-config-writers branch from ce593e0 to 335e5b4 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-config-writers branch 2 times, most recently from 6fe7012 to 653642f Compare August 28, 2026 12:26
Module codegen needs the same package.json/tsconfig/deno.json writers init
already has — they were the module writers all along, just missing the one
thing codegen adds: the typescript pin.

It is not cosmetic. The runtime mounts its own prebuilt compiler, and skips
dependency installation entirely for an otherwise dependency-free module, only
when the pin matches the engine's default; without it every `dagger call` pays
for a package-manager install. Deno has no node_modules to fall back on, so it
gets the same pin through its import map.

A module that picked its own version keeps it, and that means looking in both
dependency sections: devDependencies is where a compiler normally goes, and
writing dependencies.typescript beside one leaves the module declaring two
versions of the same package — which npm resolves to the runtime one, quietly
overriding the compiler the user chose.

Format everything we write while we are here. sjson edits in place, which reads
as "preserve the user's formatting" but only holds for the parts it does not
touch: keys it adds are appended compactly, and a file created from scratch —
every fresh module — comes out entirely inlined. Indenting reformats an
existing file's whitespace, which is a real cost, but these are committed config
files people read and edit; emitting them minified is worse. The width stays at
pretty's own default rather than zero, so a short array like the
@dagger.io/dagger path alias keeps to one line, exactly as the engine's writer
leaves it.

Two init assertions had encoded the old output shape ("type":"module" with no
space) and now read the way the file does.

Ignore the helper binaries a bare `go build` drops in a helper directory. Every
.dang caller builds them inside a Linux container, so a local one is never read
— only committed by accident.

Signed-off-by: Tom Chauveau <[email protected]>
@TomChv
TomChv force-pushed the feat/module-config-writers branch from 653642f to a247b51 Compare August 28, 2026 13:17
@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.

@TomChv TomChv closed this Aug 28, 2026
TomChv added a commit that referenced this pull request Oct 9, 2026
…erate

A module written by a v0.21 engine carries a .gitignore naming sdk/ and
__dagger.entrypoint.ts, because its runtime regenerated both on every call.
A 1.0 module commits them, the trusted runtime does no codegen, and source
loading honours .gitignore before the runtime sees the tree, so the two
lines hide the very files the module requires: `committed generated file
"sdk/client.gen.ts" is missing`, with the file on disk.

dagger/dagger#13720 taught `dagger setup` to remove exactly those lines,
but it learns them by running the legacy SDK's codegen, which an SDK-module
provider like this one does not implement, so for a module this SDK
converts the engine removes nothing — and this SDK's own dagger.json
conversion never touched the file either (SDK Main-Engine Test Run,
2026-10-07 — issue #25, case G14).

generateScope now takes the `/sdk` (or `/sdk/`) and
`/__dagger.entrypoint.ts` lines out of the module's .gitignore with the
same semantics as #13720: only those exact root-anchored lines, every other
line kept byte for byte, a removed line taking only its own terminator, the
file written only when a line went, never created, and left in place when
emptied. It runs on every generation under either loading path, because a
manifest written by an earlier SDK version or by `dagger setup` has already
lost the dagger.json that marks a migration, and before the first module
load of the run, because a workspace-backed module source applies the
.gitignore too and would hide the staged sdk/ from the self client's load.

Three e2e checks cover it on the legacy-deps fixture pair: the lines go and
the rest survives verbatim, a second generation leaves the file untouched
(asserted on the changeset layer), and a module with no .gitignore or one
naming no generated file is not written.

Signed-off-by: Tom Chauveau <[email protected]>
TomChv added a commit that referenced this pull request Oct 9, 2026
…erate

A module written by a v0.21 engine carries a .gitignore naming sdk/ and
__dagger.entrypoint.ts, because its runtime regenerated both on every call.
A 1.0 module commits them, the trusted runtime does no codegen, and source
loading honours .gitignore before the runtime sees the tree, so the two
lines hide the very files the module requires: `committed generated file
"sdk/client.gen.ts" is missing`, with the file on disk.

dagger/dagger#13720 taught `dagger setup` to remove exactly those lines,
but it learns them by running the legacy SDK's codegen, which an SDK-module
provider like this one does not implement, so for a module this SDK
converts the engine removes nothing — and this SDK's own dagger.json
conversion never touched the file either (SDK Main-Engine Test Run,
2026-10-07 — issue #25, case G14).

generateScope now takes the `/sdk` (or `/sdk/`) and
`/__dagger.entrypoint.ts` lines out of the module's .gitignore with the
same semantics as #13720: only those exact root-anchored lines, every other
line kept byte for byte, a removed line taking only its own terminator, the
file written only when a line went, never created, and left in place when
emptied. It runs on every generation under either loading path, because a
manifest written by an earlier SDK version or by `dagger setup` has already
lost the dagger.json that marks a migration, and before the first module
load of the run, because a workspace-backed module source applies the
.gitignore too and would hide the staged sdk/ from the self client's load.

Three e2e checks cover it on the legacy-deps fixture pair: the lines go and
the rest survives verbatim, a second generation leaves the file untouched
(asserted on the changeset layer), and a module with no .gitignore or one
naming no generated file is not written.

Signed-off-by: Tom Chauveau <[email protected]>
TomChv added a commit that referenced this pull request Oct 9, 2026
…erate (#76)

A module written by a v0.21 engine carries a .gitignore naming sdk/ and
__dagger.entrypoint.ts, because its runtime regenerated both on every call.
A 1.0 module commits them, the trusted runtime does no codegen, and source
loading honours .gitignore before the runtime sees the tree, so the two
lines hide the very files the module requires: `committed generated file
"sdk/client.gen.ts" is missing`, with the file on disk.

dagger/dagger#13720 taught `dagger setup` to remove exactly those lines,
but it learns them by running the legacy SDK's codegen, which an SDK-module
provider like this one does not implement, so for a module this SDK
converts the engine removes nothing — and this SDK's own dagger.json
conversion never touched the file either (SDK Main-Engine Test Run,
2026-10-07 — issue #25, case G14).

generateScope now takes the `/sdk` (or `/sdk/`) and
`/__dagger.entrypoint.ts` lines out of the module's .gitignore with the
same semantics as #13720: only those exact root-anchored lines, every other
line kept byte for byte, a removed line taking only its own terminator, the
file written only when a line went, never created, and left in place when
emptied. It runs on every generation under either loading path, because a
manifest written by an earlier SDK version or by `dagger setup` has already
lost the dagger.json that marks a migration, and before the first module
load of the run, because a workspace-backed module source applies the
.gitignore too and would hide the staged sdk/ from the self client's load.

Three e2e checks cover it on the legacy-deps fixture pair: the lines go and
the rest survives verbatim, a second generation leaves the file untouched
(asserted on the changeset layer), and a module with no .gitignore or one
naming no generated file is not written.

Signed-off-by: Tom Chauveau <[email protected]>
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