loader: support imports from vendor directories

This fixes https://github.com/tinygo-org/tinygo/issues/1518.
Этот коммит содержится в:
Ayke van Laethem 2021-01-21 15:38:15 +01:00 коммит произвёл Ron Evans
родитель a5e2b27884
коммит 36db75b366

Просмотреть файл

@ -53,6 +53,7 @@ type PackageJSON struct {
// Dependency information
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 {