@@ -776,11 +776,13 @@ let private processMemberDecls (com: IFableCompiler) ctx (fableEnt: Fable.Entity
776776 ( " FSharpUnion" :: fableEnt.Interfaces) ( Some cases) None
777777 if needsEqImpl then yield makeUnionEqualMethod fableType
778778 if needsCompImpl then yield makeUnionCompareMethod fableType ]
779- // TODO: Use specific interface for FSharpException?
780779 | Fable.Record fields
781780 | Fable.Exception fields ->
782781 let isEx = match fableEnt.Kind with Fable.Exception _ -> true | _ -> false
783- [ yield makeRecordCons isEx fields
782+ // Structs are considered equivalent to records but
783+ // some already include a constructor (see #569)
784+ [ if fableEnt.Members |> Seq.exists ( fun m -> m.Kind = Fable.Constructor) |> not
785+ then yield makeRecordCons isEx fields
784786 yield makeReflectionMeth fableEnt false fableEnt.FullName
785787 ( " FSharpRecord" :: fableEnt.Interfaces) None ( Some fields)
786788 if needsEqImpl then yield makeRecordEqualMethod fableType
@@ -1149,25 +1151,29 @@ let private getProjectMaps (com: ICompiler) (parsedProj: FSharpCheckProjectResul
11491151 try
11501152 let asmName = Path.GetFileNameWithoutExtension( asmPath)
11511153 let resolve =
1154+ // TODO: Use a case insensitive search?
11521155 match Map.tryFind asmName com.Options.refs with
11531156 | Some baseDir when baseDir.StartsWith( " ." ) ->
1154- let baseDir = Path.GetFullPath( baseDir)
1155- fun path -> Path.GetFullPath( combine baseDir path)
1157+ Path.GetFullPath( baseDir)
11561158 | Some baseDir ->
11571159 // The triple slash is just a mark to indicate
11581160 // the import must NOT be resolved with a relative path
1159- fun path -> " ///" + combine baseDir path
1161+ " ///" + baseDir
11601162 | None ->
11611163 let baseDir =
1162- let asmDir = Path.GetDirectoryName( asmPath)
1164+ let asmDir = Path.GetDirectoryName( Path.GetFullPath ( asmPath) )
11631165 // If we're compiling to a non-ES2015 module check if the referenced
11641166 // library includes a UMD distribution
11651167 if Naming.umdModules.Contains com.Options.moduleSystem
11661168 then
1167- let umdDir = Path.GetFullPath ( Path. Combine( asmDir, " umd" ) )
1169+ let umdDir = Path.Combine( asmDir, " umd" )
11681170 if Directory.Exists( umdDir) then umdDir else asmDir
11691171 else asmDir
1170- fun path -> Path.GetFullPath( combine baseDir path)
1172+ // If the assembly is an npm package, use an absolute reference
1173+ let i = baseDir.IndexOf( " node_modules/" )
1174+ if i > - 1 then " ///" + baseDir.Substring( i + 13 ) else baseDir
1175+ |> fun baseDir ->
1176+ fun path -> combine baseDir path
11711177 let fableMap =
11721178 let json = File.ReadAllText( mapPath)
11731179 Newtonsoft.Json.JsonConvert.DeserializeObject< Fable.FableMap>( json) .files
0 commit comments