Repository navigation
feat(core): add Workspace.moduleSource to load a module from a workspace - #13663
Merged
Merged
Conversation
TomChv
force-pushed
the
feat+add-workspace-modulesource-api
branch
from
July 16, 2026 17:58
653c413 to
7887bdb
Compare
TomChv
added a commit
to dagger/typescript-sdk
that referenced
this pull request
Jul 17, 2026
Replace the generated serveModuleDependencies wrapper (git-dep loop +
moduleSource(".") configExists-guarded serve + includeDependencies) with a
minimal serveBoundModule bootstrap, per dagger/dagger#13663's design.
The client schema is core + the bound module only, so there are no
dependencies to serve and includeDependencies is dead. The old
moduleSource(".") also mis-resolved once the client dir and module dir are
decoupled: it find-ups dagger.json from the client's cwd, not the module.
serveBoundModule serves exactly the one bound module, chosen by kind:
- local (LOCAL_SOURCE/DIR_SOURCE): resolve the module's workspace-root-
relative path against the workspace via dag.currentWorkspace()
.moduleSource(path) (needs Workspace.moduleSource from #13663). The path is
forced absolute (leading slash) so it resolves from the workspace root,
cwd-independent.
- git (GIT_SOURCE): serve the canonical ref + pin directly
(dag.moduleSource(ref, { refPin })), which resolves from anywhere.
The bound module's identity comes from the client entry (client.module /
.pin) plus moduleSource.kind/.asString; asString is unusable for the local
path (absolute host path for LOCAL_SOURCE, empty for DIR_SOURCE), so the
workspace-relative path is taken from client.module / the module argument.
meta.json now carries a single {kind, path, ref, pin} module object instead
of a dependencies array. Adds a golden test for both serve branches.
Depends on dagger/dagger#13663 (Workspace.moduleSource) in addition to
#13646. generateClientCompilesCheck type-checks the generated
currentWorkspace().moduleSource(...) and so requires an engine with #13663.
Signed-off-by: Tom Chauveau <[email protected]>
TomChv
force-pushed
the
feat+add-workspace-modulesource-api
branch
from
July 17, 2026 16:04
7887bdb to
eed05f8
Compare
Add a workspace-scoped `Workspace.moduleSource(path): ModuleSource!` field that resolves a path inside the workspace to a module source, using the standard workspace path rules: absolute paths from the workspace root, relative paths from the workspace cwd. It materializes the workspace tree and loads via asModuleSource, failing if the path does not point to an initialized module.
This is the runtime primitive a generated client's connect wrapper calls to serve the module it is bound to (dag.currentWorkspace().moduleSource(path).asModule().serve()), replacing the cwd-relative moduleSource(".") find-up that breaks once the client and module directories are decoupled. It also implements the API requested in #13157, so a module that receives a Workspace can load a local module from it.
Regenerate SDK bindings and reference docs for the new field, and add the generated-client-module-loading design doc.
Signed-off-by: Tom Chauveau <[email protected]>
TomChv
force-pushed
the
feat+add-workspace-modulesource-api
branch
from
July 17, 2026 16:43
eed05f8 to
4f6e6ae
Compare
tiborvass
approved these changes
Jul 17, 2026
Member
Author
|
As a follow up, we should allow path to be a ref so it can load even if the module is outside the workspace. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a workspace-scoped
Workspace.moduleSource(path): ModuleSource!field thatresolves a path inside the workspace to a
ModuleSource, using the same pathrules as
Workspace.directory/file/glob:/foo) → resolved from the workspace root.foo,../foo) → resolved from the workspace cwd(determined at load).
It materializes the workspace tree (
workspaceOverlayRootfs, so host reads routeto the workspace owner) and loads via
asModuleSource, failing if the path doesnot point to an initialized module or escapes the workspace root. Gated
AfterVersion("v1.0.0-0"),PerClientInput.Why
Two consumers:
Generated-client module loading (runtime half). A generated client's
connectwrapper needs to serve the single module it is bound to before theuser's callback runs. The old helper did
moduleSource(".")— a cwd-relativedagger.jsonfind-up that resolves to the wrong module (or nothing) now thatthe client dir and module dir are decoupled. The client can instead bake its
module's workspace-relative path and call
dag.currentWorkspace().moduleSource(path).asModule().serve(), which resolvesagainst the find-up-discovered workspace rather than the process cwd. Design:
hack/designs/generated-client-module-loading.md(added here). The codegenhalf lives in the TypeScript SDK's client generator and is handled separately.
Workspace.moduleSource(): load a module from a workspace #13157 — a module that receives a
Workspacecan now load a local modulefrom it directly, instead of reimplementing core module loading in userland.
Depends on the client-codegen schema primitives in #13646
(
ModuleSource.clientSchemaIntrospectionJSONis what makes "core + the boundmodule only" true, so the runtime only ever needs to serve the one module).
Notes
resolveClientTargetModule: itslocal/remote branch selection uses
IsLocalRef, which mis-classifies a moduledirectory whose name contains a
.as a remote ref. The input here is always alocal workspace path, so it loads the local branch directly.
Test
TestModuleSourceResolvesWorkspacePaths(core/integration/workspace_api_test.go)covers relative-from-root-cwd, relative-from-nested-cwd (
../sub), absolute(
/sub, cwd-independent), default., non-module → error, and escaping theworkspace root → error.
Closes #13157