core
core copied to clipboard
Create hashes for js files used with Require
This works as intended, and a ?h= hash is created for the .js link so that changing versions are not cached by the browser:
type MyResource() =
inherit Resources.BaseResource("test.js")
[<assembly: WebResource("test.js", "text/javascript")>]
[<assembly: Require(typeof<MyResource>)>]
do ()
But with a simplified version, currently the link is created but the hash is missing:
[<assembly: WebResource("test.js", "text/javascript")>]
[<assembly: Require(typeof<Resources.BaseResource>, "test.js")>]
do ()
This should be preferably equivalent to the code above. The cause is that BaseResource is looking up the hash using the assembly name of the current type to know where the resource might belong to (WebSharper unpacks embedded scripts by assembly so that name conflicts are not an issue). But when created via the parametrized Require attribute, it is a BaseResource instance and not a derived type which is defined by current assembly.
So this can be confusing but there is no quick and clean solution. Leaving this here for reference and discussion.