1package experimental
2
3import (
4 "context"
5
6 "github.com/tetratelabs/wazero/api"
7 "github.com/tetratelabs/wazero/internal/expctxkeys"
8)
9
10// ImportResolver is an experimental func type that, if set,
11// will be used as the first step in resolving imports.
12// See issue 2294.
13// If the import name is not found, it should return nil.
14type ImportResolver func(name string) api.Module
15
16// WithImportResolver returns a new context with the given ImportResolver.
17func WithImportResolver(ctx context.Context, resolver ImportResolver) context.Context {
18 return context.WithValue(ctx, expctxkeys.ImportResolverKey{}, resolver)
19}