Skip to content

Commit

Permalink
Fix dts transformer for "*.d" path imports (close #660)
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Jun 24, 2023
1 parent abef4d9 commit aa77015
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/dts_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,15 @@ func (task *BuildTask) toTypesPath(wd string, p NpmPackage, version string, buil
types = "index.d.ts"
}

if endsWith(types, ".d") {
pkgDir := path.Join(wd, "node_modules", p.Name)
if fileExists(path.Join(pkgDir, types+".ts")) {
types = types + ".ts"
} else if fileExists(path.Join(pkgDir, types+".mts")) {
types = types + ".mts"
}
}

if !endsWith(types, ".d.ts", ".d.mts") && !strings.HasSuffix(types, "/*") {
pkgDir := path.Join(wd, "node_modules", p.Name)
if fileExists(path.Join(pkgDir, types, "index.d.ts")) {
Expand Down

0 comments on commit aa77015

Please sign in to comment.