Skip to content

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

Draft
TomChv wants to merge 2 commits into
feat/vendor-typescript-libraryfrom
feat/packager-introspector
Draft

feat(packager): bundle the module introspector and its compiler#22
TomChv wants to merge 2 commits 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 tom@dagger.io


Stack created with GitHub Stacks CLIGive Feedback 💬

TomChv added 2 commits August 10, 2026 16:21
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 `--compile`d 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 <tom@dagger.io>
…ng it

The compiler 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 the scan still works with the compiler installed from that pin rather
than copied in. The bundle drops from ~18MB to ~9.5MB, and everything left in
it is built from the vendored source.

The cost is a registry fetch on a cold cache; committing the compiler again is
one line if offline generation ever matters.

Signed-off-by: Tom Chauveau <tom@dagger.io>
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.

1 participant