Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"encoding/binary"
"fmt"
"io"
"net/url"
"path/filepath"
"runtime/debug"
"strconv"
"strings"
Expand Down Expand Up @@ -668,6 +670,18 @@ func (s *Server) DirectoryExists(path string) bool {
return s.fs.DirectoryExists(path)
}

func fileURLToPath(rawURL string) (string, error) {
u, err := url.Parse(rawURL)
if err != nil {
return "", err
}
if u.Scheme != "file" {
return "", fmt.Errorf("not a file URL: %s", u.Scheme)
}
// On Windows, url.Path starts with "/", e.g. /C:/path/to/file
return filepath.FromSlash(u.Path), nil
}

// FileExists implements vfs.FS.
func (s *Server) FileExists(path string) bool {
if s.enabledCallbacks&CallbackFileExists != 0 {
Expand All @@ -679,6 +693,13 @@ func (s *Server) FileExists(path string) bool {
return string(result) == "true"
}
}
if strings.HasPrefix(path, "file://") {
path, err := fileURLToPath(path)
if err != nil {
panic(err)
}
return s.fs.FileExists(path)
}
return s.fs.FileExists(path)
}

Expand Down
1 change: 1 addition & 0 deletions internal/tsoptions/enummaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ var LibMap = collections.NewOrderedMapFromList([]collections.MapEntry[string, an
{Key: "deno.webgpu", Value: "lib.deno.webgpu.d.ts"},
{Key: "deno.shared_globals", Value: "lib.deno.shared_globals.d.ts"},
{Key: "deno.unstable", Value: "lib.deno.unstable.d.ts"},
{Key: "dom.extras", Value: "lib.dom.extras.d.ts"},
})

var (
Expand Down