Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Savara <pavel.savara@gmail.com>2022-06-24 15:39:19 +0300
committerGitHub <noreply@github.com>2022-06-24 15:39:19 +0300
commit50c3df750a2ad6996159100245645d010c693d87 (patch)
tree2eb0102a31c273454a1aaf6d2727df88e4ff209f /src/tasks/WasmAppBuilder/WasmAppBuilder.cs
parentb92de6bf0351280cd36221f3232b2964a4e61e88 (diff)
[wasm] Switch default modules to es6 (#70746)
switched dotnet.js to be ES6 module by making <WasmEnableES6> default true updated all samples updated functional tests updated debugger tests updated test-main updated templates Co-authored-by: Marek FiĊĦera <mara@neptuo.com> Co-authored-by: Ankit Jain <radical@gmail.com>
Diffstat (limited to 'src/tasks/WasmAppBuilder/WasmAppBuilder.cs')
-rw-r--r--src/tasks/WasmAppBuilder/WasmAppBuilder.cs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs
index 5272edc5168..83c189654a8 100644
--- a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs
+++ b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs
@@ -23,6 +23,8 @@ public class WasmAppBuilder : Task
[Required]
public string? MainJS { get; set; }
+ public string? WasmEnableES6 { get; set; }
+
[Required]
public string[] Assemblies { get; set; } = Array.Empty<string>();
@@ -195,17 +197,24 @@ public class WasmAppBuilder : Task
{
if (!File.Exists(indexHtmlPath))
{
- var html = @"<html><body><script type=""text/javascript"" src=""" + mainFileName + @"""></script></body></html>";
+ var html = @"<html><body><script type=""module"" src=""" + mainFileName + @"""></script></body></html>";
File.WriteAllText(indexHtmlPath, html);
}
}
else
{
FileCopyChecked(MainHTMLPath, Path.Combine(AppDir, indexHtmlPath), "html");
- //var html = @"<html><body><script type=""text/javascript"" src=""" + mainFileName + @"""></script></body></html>";
+ //var html = @"<html><body><script type=""module"" src=""" + mainFileName + @"""></script></body></html>";
//File.WriteAllText(indexHtmlPath, html);
}
+ string packageJsonPath = Path.Combine(AppDir, "package.json");
+ if (WasmEnableES6 != "false" && !File.Exists(packageJsonPath))
+ {
+ var json = @"{ ""type"":""module"" }";
+ File.WriteAllText(packageJsonPath, json);
+ }
+
foreach (var assembly in _assemblies)
{
config.Assets.Add(new AssemblyEntry(Path.GetFileName(assembly)));