mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
loader: support imports from vendor directories
This fixes https://github.com/tinygo-org/tinygo/issues/1518.
This commit is contained in:
committed by
Ron Evans
parent
a5e2b27884
commit
36db75b366
+5
-1
@@ -52,7 +52,8 @@ type PackageJSON struct {
|
||||
CFiles []string
|
||||
|
||||
// Dependency information
|
||||
Imports []string
|
||||
Imports []string
|
||||
ImportMap map[string]string
|
||||
|
||||
// Error information
|
||||
Error *struct {
|
||||
@@ -411,6 +412,9 @@ func (p *Package) Import(to string) (*types.Package, error) {
|
||||
if to == "unsafe" {
|
||||
return types.Unsafe, nil
|
||||
}
|
||||
if newTo, ok := p.ImportMap[to]; ok && !strings.HasSuffix(newTo, ".test]") {
|
||||
to = newTo
|
||||
}
|
||||
if imported, ok := p.program.Packages[to]; ok {
|
||||
return imported.Pkg, nil
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user