1

I am using a third party javascript file in a project that makes a call to a wasm file. Can I call this and server it the same way I do a javascript file in script tags?

Bill Greer
  • 3,046
  • 9
  • 49
  • 80
  • How are you trying to load it? Wasm usually gets loaded async with something like fetch and then given to the Web Assembly context. Is your question about serving it, loading it in the page, or something else? – zero298 Apr 05 '19 at 00:02
  • @zero298 I do not know how to load it. I have a piece of javascript that I am pulling in from a CDN and it's looking for a wasm file. When I get my hands on the wasm file I am wondering the easiest way to make it available to the other js file. Can I put the file in my scripts folder and load it the same way I would load a javascript file using script tags? I hope I have added a little clarification to my question. Thanks. – Bill Greer Apr 05 '19 at 13:34

1 Answers1

2

Yes, For Asp.Net Core we did the following to Serve the file:

    // https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.2#fileextensioncontenttypeprovider
    var provider = new FileExtensionContentTypeProvider {Mappings = {[".wasm"] = "application/wasm"}};

    app.UseStaticFiles(new StaticFileOptions
    {
        ContentTypeProvider = provider,
        ...
    }
ttugates
  • 5,818
  • 3
  • 44
  • 54