mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 14:03:39 +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
|
CFiles []string
|
||||||
|
|
||||||
// Dependency information
|
// Dependency information
|
||||||
Imports []string
|
Imports []string
|
||||||
|
ImportMap map[string]string
|
||||||
|
|
||||||
// Error information
|
// Error information
|
||||||
Error *struct {
|
Error *struct {
|
||||||
@@ -411,6 +412,9 @@ func (p *Package) Import(to string) (*types.Package, error) {
|
|||||||
if to == "unsafe" {
|
if to == "unsafe" {
|
||||||
return types.Unsafe, nil
|
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 {
|
if imported, ok := p.program.Packages[to]; ok {
|
||||||
return imported.Pkg, nil
|
return imported.Pkg, nil
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user