Skip to content

Commit 13aa2a3

Browse files
committed
Don't resolve node builtins
1 parent bebf1b5 commit 13aa2a3

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

internal/pnp/pnpapi.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,67 @@ import (
55
"os"
66
"path"
77
"path/filepath"
8+
"slices"
89
"strings"
910

1011
"github.com/microsoft/typescript-go/internal/tspath"
1112
)
1213

14+
var NODEJS_BUILTINS = []string{
15+
"assert",
16+
"assert/strict",
17+
"async_hooks",
18+
"buffer",
19+
"child_process",
20+
"cluster",
21+
"console",
22+
"constants",
23+
"crypto",
24+
"dgram",
25+
"diagnostics_channel",
26+
"dns",
27+
"dns/promises",
28+
"domain",
29+
"events",
30+
"fs",
31+
"fs/promises",
32+
"http",
33+
"http2",
34+
"https",
35+
"inspector",
36+
"module",
37+
"net",
38+
"os",
39+
"path",
40+
"path/posix",
41+
"path/win32",
42+
"perf_hooks",
43+
"process",
44+
"punycode",
45+
"querystring",
46+
"readline",
47+
"readline/promises",
48+
"repl",
49+
"stream",
50+
"stream/consumers",
51+
"stream/promises",
52+
"stream/web",
53+
"string_decoder",
54+
"sys",
55+
"timers",
56+
"timers/promises",
57+
"tls",
58+
"trace_events",
59+
"tty",
60+
"url",
61+
"util",
62+
"util/types",
63+
"v8",
64+
"vm",
65+
"worker_threads",
66+
"zlib",
67+
}
68+
1369
type PnpApi struct {
1470
url string
1571
manifest *PnpManifestData
@@ -44,6 +100,11 @@ func (p *PnpApi) ResolveToUnqualified(specifier string, parentPath string) (stri
44100
return "", nil
45101
}
46102

103+
if slices.Contains(NODEJS_BUILTINS, strings.Replace(ident, "@types/", "", 1)) {
104+
// Skipping resolution for built-in node
105+
return "", nil
106+
}
107+
47108
parentLocator, err := p.FindLocator(parentPath)
48109
if err != nil || parentLocator == nil {
49110
// Skipping resolution

0 commit comments

Comments
 (0)