Skip to content

Commit

Permalink
API take 32
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Oct 5, 2024
1 parent 2ae7889 commit a133d27
Show file tree
Hide file tree
Showing 4 changed files with 456 additions and 207 deletions.
6 changes: 4 additions & 2 deletions resources/resource_transformers/js/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ type ExternalOptions struct {
AvoidTDZ bool
}

func decodeOptions(m map[string]any) (ExternalOptions, error) {
func DecodeExternalOptions(m map[string]any) (ExternalOptions, error) {
var opts ExternalOptions

if err := mapstructure.WeakDecode(m, &opts); err != nil {
Expand Down Expand Up @@ -370,18 +370,20 @@ func createBuildPlugins(c *Client, depsManager identity.Manager, opts Options) (
build.OnResolve(api.OnResolveOptions{Filter: `^@params$`},
func(args api.OnResolveArgs) (api.OnResolveResult, error) {
return api.OnResolveResult{
Path: args.Path,
Path: args.Importer,
Namespace: nsParams,
}, nil
})
build.OnLoad(api.OnLoadOptions{Filter: `.*`, Namespace: nsParams},
func(args api.OnLoadArgs) (api.OnLoadResult, error) {
contents := bs

if opts.ImportParamsOnLoadFunc != nil {
if s := opts.ImportParamsOnLoadFunc(args); s != "" {
contents = s
}
}

return api.OnLoadResult{
Contents: &contents,
Loader: api.LoaderJSON,
Expand Down
2 changes: 1 addition & 1 deletion resources/resource_transformers/js/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (t *buildTransformation) Transform(ctx *resources.ResourceTransformationCtx
ctx.OutMediaType = media.Builtin.JavascriptType

if t.optsm != nil {
optsExt, err := decodeOptions(t.optsm)
optsExt, err := DecodeExternalOptions(t.optsm)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit a133d27

Please sign in to comment.