loader: support imports from vendor directories
This fixes https://github.com/tinygo-org/tinygo/issues/1518.
Этот коммит содержится в:
родитель
a5e2b27884
коммит
36db75b366
1 изменённых файлов: 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 {
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче