@@ -1018,7 +1018,7 @@ func (s *Session) BuildPackage(pkg *PackageData) (*compiler.Archive, error) {
10181018
10191019 importContext := & compiler.ImportContext {
10201020 Packages : s .Types ,
1021- Import : s .ImportResolverFor (pkg .Dir ),
1021+ Import : s .ImportResolverFor (pkg , pkg .Dir ),
10221022 }
10231023 archive , err := compiler .Compile (pkg .ImportPath , files , fileSet , importContext , s .options .Minify )
10241024 if err != nil {
@@ -1043,12 +1043,16 @@ func (s *Session) BuildPackage(pkg *PackageData) (*compiler.Archive, error) {
10431043
10441044// ImportResolverFor returns a function which returns a compiled package archive
10451045// given an import path.
1046- func (s * Session ) ImportResolverFor (srcDir string ) func (string ) (* compiler.Archive , error ) {
1046+ func (s * Session ) ImportResolverFor (pkg * PackageData , srcDir string ) func (string ) (* compiler.Archive , error ) {
10471047 return func (path string ) (* compiler.Archive , error ) {
10481048 if archive , ok := s .UpToDateArchives [path ]; ok {
10491049 return archive , nil
10501050 }
1051- _ , archive , err := s .buildImportPathWithSrcDir (path , srcDir )
1051+ if pkg .Dir != srcDir { // TODO(gn): REMOVE
1052+ panic ("import resolver called with different srcDir: " + srcDir + " != " + pkg .Dir )
1053+ }
1054+
1055+ _ , archive , err := s .buildImportPathWithSrcDir (path , pkg .Dir )
10521056 return archive , err
10531057 }
10541058}
@@ -1087,7 +1091,13 @@ func (s *Session) WriteCommandPackage(archive *compiler.Archive, pkgObj string)
10871091 sourceMapFilter .MappingCallback = s .SourceMappingCallback (m )
10881092 }
10891093
1090- deps , err := compiler .ImportDependencies (archive , s .ImportResolverFor ("" ))
1094+ deps , err := compiler .ImportDependencies (archive , func (path string ) (* compiler.Archive , error ) {
1095+ if archive , ok := s .UpToDateArchives [path ]; ok {
1096+ return archive , nil
1097+ }
1098+ _ , archive , err := s .buildImportPathWithSrcDir (path , "" )
1099+ return archive , err
1100+ })
10911101 if err != nil {
10921102 return err
10931103 }
0 commit comments