gofront 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/resolver.js CHANGED
@@ -25,11 +25,39 @@ function findNodeModules(startDir) {
25
25
  }
26
26
  }
27
27
 
28
+ // Built-in stdlib package paths that are always available as globals — no resolution needed.
29
+ const BUILTIN_PACKAGES = new Set([
30
+ "fmt",
31
+ "strings",
32
+ "bytes",
33
+ "strconv",
34
+ "sort",
35
+ "math",
36
+ "math/rand",
37
+ "errors",
38
+ "time",
39
+ "unicode",
40
+ "unicode/utf8",
41
+ "os",
42
+ "slices",
43
+ "html",
44
+ "io",
45
+ "gom",
46
+ "maps",
47
+ "regexp",
48
+ "path",
49
+ "path/filepath",
50
+ ]);
51
+
28
52
  // Returns true for local relative paths (start with ./ or ../)
29
53
  export function isLocalPath(importPath) {
30
54
  return importPath.startsWith("./") || importPath.startsWith("../");
31
55
  }
32
56
 
57
+ export function isBuiltinPackage(importPath) {
58
+ return BUILTIN_PACKAGES.has(importPath);
59
+ }
60
+
33
61
  // Resolve a local relative import path to an absolute directory of .go files.
34
62
  // Returns the absolute dir path, or null if it doesn't contain any .go files.
35
63
  export function resolveGwDir(importPath, fromFile) {
@@ -85,6 +113,7 @@ export function resolveAll(imports, fromFile, parseDts) {
85
113
  for (const { path } of imp.imports) {
86
114
  if (path.startsWith("js:")) continue; // handled separately
87
115
  if (isLocalPath(path)) continue; // local .go packages — handled by compiler
116
+ if (isBuiltinPackage(path)) continue; // built-in stdlib namespaces — always available
88
117
 
89
118
  if (resolved.has(path)) continue;
90
119