core
core copied to clipboard
Failed to load type to `Resources.BaseResource` when compiling using `bundleOnly`
Hello,
I am using a custom QUnit binding for my project
namespace WebSharper.QUnit
open WebSharper
open WebSharper.JavaScript
module Resources =
[<Sealed>]
type QUnit() =
inherit Resources.BaseResource("https://code.jquery.com/qunit/",
"qunit-2.24.1.js", "qunit-2.24.1.css")
[<Require(typeof<Resources.QUnit>)>]
type QUnit =
[<Inline "QUnit.module($name)">]
static member Module (name: string) = ()
[<Inline "QUnit.module($name, $callback)">]
static member Module (name: string, callback : obj -> unit) = ()
// ...
However when compiling the project as bundleOnly WebSharper generate an error in the *.head.* files:
Tests.head.html
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/9.4.4/math.js" type="text/javascript" charset="UTF-8"></script><!-- Failed to load: { Assembly = "Motivity.Thoth.Json.Tests"
FullName = "WebSharper.QUnit.Resources+QUnit" }; because of: Failed to load type WebSharper.QUnit.Resources+QUnit from assembly Motivity.Thoth.Json.Tests: System.TypeLoadException: Could not load type 'WebSharper.QUnit.Resources' from assembly 'Motivity.Thoth.Json.Tests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
at System.Reflection.RuntimeAssembly.GetTypeCore(String typeName, ReadOnlySpan`1 nestedTypeNames, Boolean throwOnError, Boolean ignoreCase)
at System.Reflection.TypeNameResolver.GetType(String escapedTypeName, ReadOnlySpan`1 nestedTypeNames, TypeName parsedName)
at System.Reflection.TypeNameResolver.Resolve(TypeName typeName)
at System.Reflection.TypeNameResolver.GetType(String typeName, Func`2 assemblyResolver, Func`4 typeResolver, Assembly requestingAssembly, Boolean throwOnError, Boolean ignoreCase, Boolean extensibleParser)
at System.Type.GetType(String typeName, Boolean throwOnError)
at WebSharper.Core.AST.Reflection.LoadTypeDefinition(Hashed`1 td) -->
Tests.head.js
document.write("<script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjs/9.4.4/math.js\" type=\"text/javascript\" charset=\"UTF-8\"></script><!-- Failed to load: { Assembly = \"Motivity.Thoth.Json.Tests\"\n FullName = \"WebSharper.QUnit.Resources+QUnit\" }; because of: Failed to load type WebSharper.QUnit.Resources+QUnit from assembly Motivity.Thoth.Json.Tests: System.TypeLoadException: Could not load type 'WebSharper.QUnit.Resources' from assembly 'Motivity.Thoth.Json.Tests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.\r\n at System.Reflection.RuntimeAssembly.GetTypeCore(String typeName, ReadOnlySpan`1 nestedTypeNames, Boolean throwOnError, Boolean ignoreCase)\r\n at System.Reflection.TypeNameResolver.GetType(String escapedTypeName, ReadOnlySpan`1 nestedTypeNames, TypeName parsedName)\r\n at System.Reflection.TypeNameResolver.Resolve(TypeName typeName)\r\n at System.Reflection.TypeNameResolver.GetType(String typeName, Func`2 assemblyResolver, Func`4 typeResolver, Assembly requestingAssembly, Boolean throwOnError, Boolean ignoreCase, Boolean extensibleParser)\r\n at System.Type.GetType(String typeName, Boolean throwOnError)\r\n at WebSharper.Core.AST.Reflection.LoadTypeDefinition(Hashed`1 td) -->\r\n")
Workaround is to not use Resources.BaseResource mechanism from WebSharper and manually include the library in the index.html file