MCPcopy
hub / github.com/esm-dev/esm.sh / resloveSubModule

Method resloveSubModule

server/build_resolver.go:1162–1181  ·  view source on GitHub ↗
(subPath string)

Source from the content-addressed store, hash-verified

1160}
1161
1162func (ctx *BuildContext) resloveSubModule(subPath string) (string, bool) {
1163 if subPath != "" {
1164 if ctx.existsPkgFile(subPath) {
1165 return subPath, true
1166 }
1167 preferExt := ".mjs"
1168 if ctx.pkgJson.Type == "commonjs" {
1169 preferExt = ".cjs"
1170 }
1171 for _, ext := range []string{preferExt, "js", "mts", "ts", "cts"} {
1172 if ctx.existsPkgFile(subPath + "." + ext) {
1173 return subPath + "." + ext, true
1174 }
1175 if ctx.existsPkgFile(subPath + "/index." + ext) {
1176 return subPath + "/index." + ext, true
1177 }
1178 }
1179 }
1180 return "", false
1181}
1182
1183func (ctx *BuildContext) resolveDependency(specifier string, isDts bool) (esm EsmPath, packageJson *npm.PackageJSON, err error) {
1184 pkgName, version, subPath := splitEsmPath(specifier)

Callers 1

resolveEntryMethod · 0.95

Calls 1

existsPkgFileMethod · 0.95

Tested by

no test coverage detected