{{ $imports := dict }}

{{ if eq 0 1 }}
  {{ with $tsModuleResources := resources.Match "scripts/modules/*/*" }}
    {{ range $tsModuleResources }}
      {{ $resource := . }}
      {{ if eq (path.Ext .) ".ts" }}
        {{ $resource = . | js.Build }}
      {{ end }}

      {{/*
      Create imports for these scripts that look like $dirname/$basename
      where basename doesn't have the extension
      */}}
      {{ $directoryBasename := path.Base (path.Dir $resource) }}
      {{ $key := path.Join $directoryBasename (path.BaseName $resource) }}

      {{ $imports = merge $imports (dict $key $resource.RelPermalink) }}
    {{ end }}
  {{ end }}
{{ else }}
  {{ $imports = dict "modules/" "scripts/modules/" }}
{{ end }}

{{ $importmap := dict }}
{{ if gt (len $imports) 0 }}
  {{ $importmap = dict "imports" $imports }}
{{ end }}

{{ return $importmap }}
