Skip to content

feat(packager): bundle the module introspector - #22

Closed
TomChv wants to merge 1 commit into
feat/vendor-typescript-libraryfrom
feat/packager-introspector
Closed

TomChv wants to merge 1 commit into
feat/vendor-typescript-libraryfrom
feat/packager-introspector

Conversation

@TomChv

@TomChv TomChv commented Aug 10, 2026

Copy link
Copy Markdown
Member

Entrypoint generation scans a module's TypeScript with the compiler API, so the
scanner and the compiler have to come from somewhere. The engine ships both in
its image; we build the scanner from the vendored source and carry the compiler
next to it.

The scanner is a plain bun build, not the --compiled binary the engine
ships: that is ~100MB and per-platform, where this is portable JS. The compiler
stays external to it and is trimmed to package.json + lib/typescript.js, which
resolves because TypeScript 6 declares no exports map and points main straight
at that file.

Verified before anything depends on it: with the compiler mounted at
node_modules/typescript, the bundled scanner runs over a fixture module and
emits a typedef.json carrying the per-declaration source locations the
entrypoint renderer consumes.

index.ts and telemetry.ts join them — the module-facing wrappers that make sdk/
resolvable as @dagger.io/dagger. They are taken from the v1.0.0-beta.9 tag, not
from upstream's working tree, which re-exports an agent symbol this engine's
core.js does not have; every name they re-export is checked against the bundle.

The bundle now costs ~18MB committed, over half of it the compiler.

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


Stack created with GitHub Stacks CLI • Give Feedback 💬

@TomChv
TomChv force-pushed the feat/packager-introspector branch from 5b9e4e1 to 09abdd7 Compare August 21, 2026 12:11
@TomChv
TomChv force-pushed the feat/packager-introspector branch from 09abdd7 to 0bd79a0 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/packager-introspector branch from 0bd79a0 to 9f5d39e Compare August 28, 2026 11:24
@TomChv TomChv changed the title feat(packager): bundle the module introspector and its compiler feat(packager): bundle the module introspector Aug 28, 2026
@TomChv
TomChv force-pushed the feat/packager-introspector branch from 9f5d39e to 4d9844b Compare August 28, 2026 12:26
Entrypoint generation scans a module's TypeScript with the compiler API, so the
scanner and the compiler have to come from somewhere. The engine ships both in
its image; we build the scanner from the vendored source and let codegen
install the compiler.

The scanner is a plain `bun build`, not the `--compile`d binary the engine
ships: that is ~100MB and per-platform, where this is portable JS.

The compiler is not shipped with it. It is a build-time dependency of the
scanner, not something a user's module consumes: the scanner calls the API of
the version the vendored library locks (6.0.3), while a module declares 5.9.3
for its own runtime. Carrying 9.1MB of third-party blob in git, re-committed on
every engine bump, to serve one exec is the wrong trade — codegen installs it,
pinned, so the layer is content-addressed on the version alone and shared
across every module's generate.

The version is derived rather than hand-written: the packager reads it off the
resolved install into bundle/typescript-version.txt, so re-vendoring cannot
silently move the scanner onto a compiler API it was not written against.

Verified before anything depends on it: with the compiler installed from that
pin, the bundled scanner runs over a fixture module and emits a typedef.json
carrying the per-declaration source locations the entrypoint renderer consumes.

index.ts and telemetry.ts join it — the module-facing wrappers that make sdk/
resolvable as @dagger.io/dagger. They are taken from the v1.0.0-beta.9 tag, not
from upstream's working tree, which re-exports an `agent` symbol this engine's
core.js does not have; every name they re-export is checked against the bundle.

The bundle costs ~9.5MB committed, and everything in it is built from the
vendored source. The cost is a registry fetch on a cold cache; committing the
compiler instead is one line if offline generation ever matters.

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