-
-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Labels
enhancementNew feature or enhancementNew feature or enhancementexternalThe issue is caused by a third-partyThe issue is caused by a third-party
Milestone
Description
We are currently patching .NET's and Emscripten's JavaScript modules to make them compatible with JavaScript runtimes and bundlers:
File.WriteAllText(dotnet, File.ReadAllText(dotnet, Encoding.UTF8) | |
.Replace("import.meta.url", url) | |
.Replace("import(", "import(/*@vite-ignore*//*webpackIgnore:true*/"), Encoding.UTF8); | |
File.WriteAllText(runtime, File.ReadAllText(runtime, Encoding.UTF8) | |
.Replace("pt('WebAssembly resource does not have the expected content type \"application/wasm\", so falling back to slower ArrayBuffer instantiation.')", "true") | |
.Replace("import(", "import(/*@vite-ignore*//*webpackIgnore:true*/"), Encoding.UTF8); | |
File.WriteAllText(native, File.ReadAllText(native, Encoding.UTF8) | |
.Replace("var _scriptDir = import.meta.url", "var _scriptDir = \"file:/\"") | |
.Replace("require('url').fileURLToPath(new URL('./', import.meta.url))", "\"./\"") | |
.Replace("require(\"url\").fileURLToPath(new URL(\"./\",import.meta.url))", "\"./\"") // when aggressive trimming enabled | |
.Replace("new URL('dotnet.native.wasm', import.meta.url).href", "\"file:/\"") | |
.Replace("new URL(\"dotnet.native.wasm\",import.meta.url).href", "\"file:/\"") // when aggressive trimming enabled | |
.Replace("import.meta.url", url) | |
.Replace("import(", "import(/*@vite-ignore*//*webpackIgnore:true*/"), Encoding.UTF8); |
— this is fragile and will most likely break with each new .NET release and/or WASM workload update.
Hopefully, .NET will at some point ensure the modules are compatible out of the box, so we won't have to do this:
skgrush
Metadata
Metadata
Assignees
Labels
enhancementNew feature or enhancementNew feature or enhancementexternalThe issue is caused by a third-partyThe issue is caused by a third-party