[wasm] remove support for CommonJS (#72865)
authorPavel Savara <pavel.savara@gmail.com>
Thu, 28 Jul 2022 08:20:58 +0000 (10:20 +0200)
committerGitHub <noreply@github.com>
Thu, 28 Jul 2022 08:20:58 +0000 (10:20 +0200)
56 files changed:
eng/liveBuilds.targets
eng/testing/tests.wasm.targets
src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props
src/mono/sample/wasm/browser-cjs/Makefile [deleted file]
src/mono/sample/wasm/browser-cjs/Program.cs [deleted file]
src/mono/sample/wasm/browser-cjs/Wasm.Browser.CJS.Sample.csproj [deleted file]
src/mono/sample/wasm/browser-cjs/index.html [deleted file]
src/mono/sample/wasm/browser-cjs/main.js [deleted file]
src/mono/sample/wasm/browser-legacy/Program.cs [deleted file]
src/mono/sample/wasm/browser-legacy/Wasm.Browser.LegacySample.csproj [deleted file]
src/mono/sample/wasm/browser-legacy/index.html [deleted file]
src/mono/sample/wasm/browser-legacy/main.js [deleted file]
src/mono/sample/wasm/browser-mt-eventpipe/index.html
src/mono/sample/wasm/browser/Makefile
src/mono/sample/wasm/browser/Wasm.Browser.Sample.csproj [moved from src/mono/sample/wasm/browser/Wasm.Browser.ES6.Sample.csproj with 92% similarity]
src/mono/sample/wasm/browser/index.html
src/mono/sample/wasm/browser/main.js
src/mono/sample/wasm/console-node-cjs/Makefile [deleted file]
src/mono/sample/wasm/console-node-cjs/Program.cs [deleted file]
src/mono/sample/wasm/console-node-cjs/README.md [deleted file]
src/mono/sample/wasm/console-node-cjs/Wasm.Console.Node.CJS.Sample.csproj [deleted file]
src/mono/sample/wasm/console-node-cjs/main.cjs [deleted file]
src/mono/sample/wasm/console-node-cjs/package.json [deleted file]
src/mono/sample/wasm/console-node-es6/Makefile
src/mono/sample/wasm/console-node-es6/Wasm.Console.Node.Sample.csproj [moved from src/mono/sample/wasm/console-node-es6/Wasm.Console.Node.ES6.Sample.csproj with 86% similarity]
src/mono/sample/wasm/console-node-es6/main.mjs
src/mono/sample/wasm/console-node-ts/Makefile
src/mono/sample/wasm/console-v8-cjs/Makefile [deleted file]
src/mono/sample/wasm/console-v8-cjs/Program.cs [deleted file]
src/mono/sample/wasm/console-v8-cjs/Wasm.Console.V8.CJS.Sample.csproj [deleted file]
src/mono/sample/wasm/console-v8-cjs/main.cjs [deleted file]
src/mono/sample/wasm/console-v8-es6/Makefile
src/mono/sample/wasm/console-v8-es6/Wasm.Console.V8.Sample.csproj [moved from src/mono/sample/wasm/console-v8-es6/Wasm.Console.V8.ES6.Sample.csproj with 85% similarity]
src/mono/sample/wasm/console-v8-es6/main.mjs
src/mono/wasm/README.md
src/mono/wasm/build/README.md
src/mono/wasm/build/WasmApp.Native.targets
src/mono/wasm/build/WasmApp.targets
src/mono/wasm/debugger/DebuggerTestSuite/ArrayTests.cs
src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs
src/mono/wasm/runtime/.eslintrc.cjs
src/mono/wasm/runtime/cjs/dotnet.cjs.extpost.js [deleted file]
src/mono/wasm/runtime/cjs/dotnet.cjs.lib.js [deleted file]
src/mono/wasm/runtime/cjs/dotnet.cjs.post.js [deleted file]
src/mono/wasm/runtime/cjs/dotnet.cjs.pre.js [deleted file]
src/mono/wasm/runtime/diagnostics/server_pthread/mock-remote.ts
src/mono/wasm/runtime/es6/dotnet.es6.lib.js
src/mono/wasm/runtime/exports.ts
src/mono/wasm/runtime/imports.ts
src/mono/wasm/runtime/modularize-dotnet.md
src/mono/wasm/runtime/polyfills.ts
src/mono/wasm/runtime/rollup.config.js
src/mono/wasm/runtime/types.ts
src/mono/wasm/test-main.js
src/mono/wasm/wasm.proj
src/tasks/WasmAppBuilder/WasmAppBuilder.cs

index fcda36b..44a60fc 100644 (file)
         NativeSubDirectory="src"
         IsNative="true" />
       <LibrariesRuntimeFiles Condition="'$(TargetOS)' == 'Browser'"
-                             Include="$(LibrariesNativeArtifactsPath)src\cjs\*.js"
-                             NativeSubDirectory="src\cjs"
-                             IsNative="true" />
-      <LibrariesRuntimeFiles Condition="'$(TargetOS)' == 'Browser'"
                              Include="$(LibrariesNativeArtifactsPath)src\es6\*.js"
                              NativeSubDirectory="src\es6"
                              IsNative="true" />
index 689378e..398c0b1 100644 (file)
       <_WasmPropertyNames Include="WasmDedup" />
       <_WasmPropertyNames Include="WasmLinkIcalls" />
       <_WasmPropertyNames Include="WasmNativeStrip" />
-      <_WasmPropertyNames Include="WasmEnableES6" />
       <_WasmPropertyNames Include="_WasmDevel" />
       <_WasmPropertyNames Include="_WasmStrictVersionMatch" />
       <_WasmPropertyNames Include="WasmEmitSymbolMap" />
index f819438..42c107d 100644 (file)
     <PlatformManifestFileEntry Include="icudt_optimal_no_CJK.dat" IsNative="true" />
     <PlatformManifestFileEntry Include="package.json" IsNative="true" />
     <PlatformManifestFileEntry Include="pal_random.lib.js" IsNative="true" />
-    <PlatformManifestFileEntry Include="runtime.cjs.iffe.js" IsNative="true" />
-    <PlatformManifestFileEntry Include="dotnet.cjs.lib.js" IsNative="true" />
-    <PlatformManifestFileEntry Include="dotnet.cjs.pre.js" IsNative="true" />
-    <PlatformManifestFileEntry Include="dotnet.cjs.post.js" IsNative="true" />
-    <PlatformManifestFileEntry Include="dotnet.cjs.extpost.js" IsNative="true" />
     <PlatformManifestFileEntry Include="runtime.es6.iffe.js" IsNative="true" />
     <PlatformManifestFileEntry Include="dotnet.es6.pre.js" IsNative="true" />
     <PlatformManifestFileEntry Include="dotnet.es6.lib.js" IsNative="true" />
diff --git a/src/mono/sample/wasm/browser-cjs/Makefile b/src/mono/sample/wasm/browser-cjs/Makefile
deleted file mode 100644 (file)
index 7a6b17c..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-TOP=../../../../..
-
-include ../wasm.mk
-
-ifneq ($(AOT),)
-override MSBUILD_ARGS+=/p:RunAOTCompilation=true
-endif
-
-PROJECT_NAME=Wasm.Browser.CJS.Sample.csproj
-
-run: run-browser
diff --git a/src/mono/sample/wasm/browser-cjs/Program.cs b/src/mono/sample/wasm/browser-cjs/Program.cs
deleted file mode 100644 (file)
index 743f481..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Runtime.CompilerServices;
-
-namespace Sample
-{
-    public class Test
-    {
-        public static void Main(string[] args)
-        {
-            Console.WriteLine ("Hello, World!");
-        }
-
-        [MethodImpl(MethodImplOptions.NoInlining)]
-        public static int TestMeaning()
-        {
-            return 42;
-        }
-    }
-}
diff --git a/src/mono/sample/wasm/browser-cjs/Wasm.Browser.CJS.Sample.csproj b/src/mono/sample/wasm/browser-cjs/Wasm.Browser.CJS.Sample.csproj
deleted file mode 100644 (file)
index d836a85..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-  <PropertyGroup>
-    <WasmCopyAppZipToHelixTestDir Condition="'$(ArchiveTests)' == 'true'">true</WasmCopyAppZipToHelixTestDir>
-    <WasmMainJSPath>main.js</WasmMainJSPath>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>embedded</DebugType>
-    <WasmDebugLevel>1</WasmDebugLevel>
-    <WasmEnableES6>false</WasmEnableES6>
-
-    <GenerateRunScriptForSample Condition="'$(ArchiveTests)' == 'true'">true</GenerateRunScriptForSample>
-    <RunScriptCommand>$(ExecXHarnessCmd) wasm test-browser  --app=. --browser=Chrome $(XHarnessBrowserPathArg) --html-file=index.html --output-directory=$(XHarnessOutput) -- $(MSBuildProjectName).dll</RunScriptCommand>
-  </PropertyGroup>
-
-  <ItemGroup>
-    <WasmExtraFilesToDeploy Include="index.html" />
-  </ItemGroup>
-
-  <PropertyGroup>
-    <_SampleProject>Wasm.Browser.CJS.Sample.csproj</_SampleProject>
-  </PropertyGroup>
-
-  <Target Name="RunSample" DependsOnTargets="RunSampleWithBrowser" />
-</Project>
diff --git a/src/mono/sample/wasm/browser-cjs/index.html b/src/mono/sample/wasm/browser-cjs/index.html
deleted file mode 100644 (file)
index bc5a8c1..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<!--  Licensed to the .NET Foundation under one or more agreements. -->
-<!-- The .NET Foundation licenses this file to you under the MIT license. -->
-<html>
-
-<head>
-  <title>Sample CJS</title>
-  <meta charset="UTF-8">
-  <meta name="viewport" content="width=device-width, initial-scale=1.0">
-</head>
-
-<body>
-  <h3 id="header">Wasm Browser CJS Sample</h3>
-  Answer to the Ultimate Question of Life, the Universe, and Everything is : <span id="out"></span>
-  <script type="text/javascript" src="./main.js"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/src/mono/sample/wasm/browser-cjs/main.js b/src/mono/sample/wasm/browser-cjs/main.js
deleted file mode 100644 (file)
index a5bc270..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-function wasm_exit(exit_code, reason) {
-    /* Set result in a tests_done element, to be read by xharness in runonly CI test */
-    const tests_done_elem = document.createElement("label");
-    tests_done_elem.id = "tests_done";
-    tests_done_elem.innerHTML = exit_code.toString();
-    if (exit_code) tests_done_elem.style.background = "red";
-    document.body.appendChild(tests_done_elem);
-
-    if (reason) console.error(reason);
-    console.log(`WASM EXIT ${exit_code}`);
-}
-
-async function loadDotnet(file) {
-    const cjsExport = new Promise((resolve) => {
-        globalThis.__onDotnetRuntimeLoaded = (createDotnetRuntime) => {
-            delete globalThis.__onDotnetRuntimeLoaded;
-            resolve(createDotnetRuntime);
-        };
-    });
-
-    await import(file);
-    return await cjsExport;
-}
-
-
-async function main() {
-    try {
-        const createDotnetRuntime = await loadDotnet("./dotnet.js");
-        const { MONO, BINDING, Module, RuntimeBuildInfo } = await createDotnetRuntime(() => ({
-            disableDotnet6Compatibility: true,
-            configSrc: "./mono-config.json",
-        }));
-
-        const testMeaning = BINDING.bind_static_method("[Wasm.Browser.CJS.Sample] Sample.Test:TestMeaning");
-        const ret = testMeaning();
-        document.getElementById("out").innerHTML = `${ret} as computed on dotnet ver ${RuntimeBuildInfo.ProductVersion}`;
-
-        console.debug(`ret: ${ret}`);
-        let exit_code = ret == 42 ? 0 : 1;
-        wasm_exit(exit_code);
-    } catch (err) {
-        wasm_exit(2, err)
-    }
-}
-
-main();
\ No newline at end of file
diff --git a/src/mono/sample/wasm/browser-legacy/Program.cs b/src/mono/sample/wasm/browser-legacy/Program.cs
deleted file mode 100644 (file)
index 743f481..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Runtime.CompilerServices;
-
-namespace Sample
-{
-    public class Test
-    {
-        public static void Main(string[] args)
-        {
-            Console.WriteLine ("Hello, World!");
-        }
-
-        [MethodImpl(MethodImplOptions.NoInlining)]
-        public static int TestMeaning()
-        {
-            return 42;
-        }
-    }
-}
diff --git a/src/mono/sample/wasm/browser-legacy/Wasm.Browser.LegacySample.csproj b/src/mono/sample/wasm/browser-legacy/Wasm.Browser.LegacySample.csproj
deleted file mode 100644 (file)
index a105c68..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-  <PropertyGroup>
-    <WasmCopyAppZipToHelixTestDir Condition="'$(ArchiveTests)' == 'true'">true</WasmCopyAppZipToHelixTestDir>
-    <WasmMainJSPath>main.js</WasmMainJSPath>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>embedded</DebugType>
-    <WasmDebugLevel>1</WasmDebugLevel>
-    <WasmEnableES6>false</WasmEnableES6>
-    <RunAOTCompilation>false</RunAOTCompilation>
-  </PropertyGroup>
-
-  <ItemGroup>
-    <WasmExtraFilesToDeploy Include="index.html" />
-  </ItemGroup>
-
-  <PropertyGroup>
-    <_SampleProject>Wasm.Browser.LegacySample.csproj</_SampleProject>
-  </PropertyGroup>
-
-  <Target Name="RunSample" DependsOnTargets="RunSampleWithBrowser" />
-</Project>
diff --git a/src/mono/sample/wasm/browser-legacy/index.html b/src/mono/sample/wasm/browser-legacy/index.html
deleted file mode 100644 (file)
index d20eec2..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE html>
-<!--  Licensed to the .NET Foundation under one or more agreements. -->
-<!-- The .NET Foundation licenses this file to you under the MIT license. -->
-<html>
-
-<head>
-  <title>Legacy global module sample</title>
-  <meta charset="UTF-8">
-  <meta name="viewport" content="width=device-width, initial-scale=1.0">
-</head>
-
-<body>
-  <h3 id="header">Wasm Browser Legacy Sample</h3>
-  Result from Sample.Test.TestMeaning: <span id="out"></span>
-  <script type='text/javascript'>
-    function wasm_exit(exit_code, reason) {
-      /* Set result in a tests_done element, to be read by xharness */
-      const tests_done_elem = document.createElement("label");
-      tests_done_elem.id = "tests_done";
-      tests_done_elem.innerHTML = exit_code.toString();
-      if (exit_code) tests_done_elem.style.background = "red";
-      document.body.appendChild(tests_done_elem);
-
-      if(reason) console.error(reason);
-      console.log(`WASM EXIT ${exit_code}`);
-    };
-
-    const App = {
-      init: function () {
-        const testMeaning = BINDING.bind_static_method("[Wasm.Browser.LegacySample] Sample.Test:TestMeaning");
-        const ret = testMeaning();
-        document.getElementById("out").innerHTML = ret;
-
-        console.debug(`ret: ${ret}`);
-        let exit_code = ret == 42 ? 0 : 1;
-        wasm_exit(exit_code);
-      },
-    };
-  </script>
-  <script type="text/javascript" src="./main.js"></script>
-
-  <script defer src="./dotnet.js"></script>
-
-</body>
-
-</html>
\ No newline at end of file
diff --git a/src/mono/sample/wasm/browser-legacy/main.js b/src/mono/sample/wasm/browser-legacy/main.js
deleted file mode 100644 (file)
index 200dd3d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-"use strict";
-var Module = {
-    configSrc: "./mono-config.json",
-    onDotnetReady: () => {
-        try {
-            App.init();
-        } catch (error) {
-            wasm_exit(1, error);
-            throw (error);
-        }
-    },
-    onAbort: (error) => {
-        wasm_exit(1, error);
-    },
-};
index 16e4fa4..e3b3095 100644 (file)
@@ -4,7 +4,7 @@
 <html>
 
 <head>
-  <title>Sample CJS</title>
+  <title>Sample event pipe</title>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link rel="modulepreload" href="./main.js" />
@@ -12,7 +12,7 @@
 </head>
 
 <body>
-  <h3 id="header">Wasm Browser CJS Sample</h3>
+  <h3 id="header">Wasm Browser Event Pipe Sample</h3>
   Answer to the Ultimate Question of Life, the Universe, and Everything is : <span id="out"></span>
   <script type="module" src="./dotnet.worker.js"></script>
   <script type="module" src="./main.js"></script>
index 6be5669..7ae388c 100644 (file)
@@ -6,6 +6,6 @@ ifneq ($(AOT),)
 override MSBUILD_ARGS+=/p:RunAOTCompilation=true
 endif
 
-PROJECT_NAME=Wasm.Browser.ES6.Sample.csproj
+PROJECT_NAME=Wasm.Browser.Sample.csproj
 
 run: run-browser
@@ -12,7 +12,7 @@
     <WasmExtraFilesToDeploy Include="index.html" />
   </ItemGroup>
   <PropertyGroup>
-    <_SampleProject>Wasm.Browser.ES6.Sample.csproj</_SampleProject>
+    <_SampleProject>Wasm.Browser.Sample.csproj</_SampleProject>
   </PropertyGroup>
   <Target Name="RunSample" DependsOnTargets="RunSampleWithBrowser" />
 </Project>
index 9172b63..cee61db 100644 (file)
@@ -4,7 +4,7 @@
 <html>
 
 <head>
-  <title>Sample ES6</title>
+  <title>Wasm Browser Sample</title>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link rel="modulepreload" href="./main.js" />
@@ -12,7 +12,7 @@
 </head>
 
 <body>
-  <h3 id="header">Wasm Browser ES6 Sample</h3>
+  <h3 id="header">Wasm Browser Sample</h3>
   Answer to the Ultimate Question of Life, the Universe, and Everything is : <span id="out"></span>
   <script type='module' src="./main.js"></script>
 </body>
index 5198bac..4945a5c 100644 (file)
@@ -39,7 +39,7 @@ try {
         }
     };
 
-    const exports = await MONO.mono_wasm_get_assembly_exports("Wasm.Browser.ES6.Sample.dll");
+    const exports = await MONO.mono_wasm_get_assembly_exports("Wasm.Browser.Sample.dll");
     const meaning = exports.Sample.Test.TestMeaning();
     console.debug(`meaning: ${meaning}`);
     if (!exports.Sample.Test.IsPrime(meaning)) {
@@ -47,7 +47,7 @@ try {
         console.debug(`ret: ${meaning}`);
     }
 
-    let exit_code = await MONO.mono_run_main("Wasm.Browser.ES6.Sample.dll", []);
+    let exit_code = await MONO.mono_run_main("Wasm.Browser.Sample.dll", []);
     wasm_exit(exit_code);
 } catch (err) {
     wasm_exit(2, err);
diff --git a/src/mono/sample/wasm/console-node-cjs/Makefile b/src/mono/sample/wasm/console-node-cjs/Makefile
deleted file mode 100644 (file)
index 5d6de5e..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-TOP=../../../../..
-
-include ../wasm.mk
-
-ifneq ($(AOT),)
-override MSBUILD_ARGS+=/p:RunAOTCompilation=true
-endif
-
-ifneq ($(V),)
-DOTNET_MONO_LOG_LEVEL=--setenv=MONO_LOG_LEVEL=debug
-endif
-
-PROJECT_NAME=Wasm.Console.Node.CJS.Sample.csproj
-CONSOLE_DLL=Wasm.Console.Node.CJS.Sample.dll
-MAIN_JS=main.cjs
-
-run: run-console-node
diff --git a/src/mono/sample/wasm/console-node-cjs/Program.cs b/src/mono/sample/wasm/console-node-cjs/Program.cs
deleted file mode 100644 (file)
index f65bd65..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Threading.Tasks;
-
-public class Test
-{
-    public static async Task<int> Main(string[] args)
-    {
-        await Task.Delay(1);
-        Console.WriteLine("Hello World!");
-        return 42;
-    }
-}
diff --git a/src/mono/sample/wasm/console-node-cjs/README.md b/src/mono/sample/wasm/console-node-cjs/README.md
deleted file mode 100644 (file)
index 14ccf62..0000000
+++ /dev/null
@@ -1 +0,0 @@
-This sample uses CommonJS version of `dotnet.js` running on NodeJS
\ No newline at end of file
diff --git a/src/mono/sample/wasm/console-node-cjs/Wasm.Console.Node.CJS.Sample.csproj b/src/mono/sample/wasm/console-node-cjs/Wasm.Console.Node.CJS.Sample.csproj
deleted file mode 100644 (file)
index ad43d46..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-  <PropertyGroup>
-    <WasmCopyAppZipToHelixTestDir Condition="'$(ArchiveTests)' == 'true'">true</WasmCopyAppZipToHelixTestDir>
-    <WasmMainJSPath>main.cjs</WasmMainJSPath>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>embedded</DebugType>
-    <WasmDebugLevel>1</WasmDebugLevel>
-    <WasmEnableES6>false</WasmEnableES6>
-    <RunAOTCompilation>false</RunAOTCompilation>
-
-    <GenerateRunScriptForSample Condition="'$(ArchiveTests)' == 'true'">true</GenerateRunScriptForSample>
-    <ExpectedExitCode>42</ExpectedExitCode>
-    <RunScriptCommand>$(ExecXHarnessCmd) wasm test --app=. --engine=NodeJS --engine-arg=--stack-trace-limit=1000 --js-file=main.cjs --output-directory=$(XHarnessOutput) --expected-exit-code $(ExpectedExitCode) -- --run $(MSBuildProjectName).dll</RunScriptCommand>
-  </PropertyGroup>
-  
-  <ItemGroup>
-    <WasmExtraFilesToDeploy Include="package.json" />
-  </ItemGroup>
-
-  <PropertyGroup>
-    <_SampleProject>Wasm.Console.Node.CJS.Sample.csproj</_SampleProject>
-    <_SampleAssembly>Wasm.Console.Node.CJS.Sample.dll</_SampleAssembly>
-  </PropertyGroup>
-
-  <Target Name="RunSample" DependsOnTargets="RunSampleWithNode" />
-</Project>
diff --git a/src/mono/sample/wasm/console-node-cjs/main.cjs b/src/mono/sample/wasm/console-node-cjs/main.cjs
deleted file mode 100644 (file)
index 4e98507..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-const createDotnetRuntime = require("./dotnet.js");
-
-async function main() {
-    const { MONO } = await createDotnetRuntime();
-    const app_args = process.argv.slice(2);
-    const dllName = "Wasm.Console.Node.CJS.Sample.dll";
-    await MONO.mono_run_main_and_exit(dllName, app_args);
-};
-main();
diff --git a/src/mono/sample/wasm/console-node-cjs/package.json b/src/mono/sample/wasm/console-node-cjs/package.json
deleted file mode 100644 (file)
index 6a0d2ef..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-    "type": "commonjs"
-}
\ No newline at end of file
index a97fd62..29ca6a6 100644 (file)
@@ -10,8 +10,8 @@ ifneq ($(V),)
 DOTNET_MONO_LOG_LEVEL=--setenv=MONO_LOG_LEVEL=debug
 endif
 
-PROJECT_NAME=Wasm.Console.Node.ES6.Sample.csproj
-CONSOLE_DLL=Wasm.Console.Node.ES6.Sample.dll
+PROJECT_NAME=Wasm.Console.Node.Sample.csproj
+CONSOLE_DLL=Wasm.Console.Node.Sample.dll
 MAIN_JS=main.mjs
 
 run: run-console-node
@@ -14,8 +14,8 @@
   </ItemGroup>
 
   <PropertyGroup>
-    <_SampleProject>Wasm.Console.Node.ES6.Sample.csproj</_SampleProject>
-    <_SampleAssembly>Wasm.Console.Node.ES6.Sample.dll</_SampleAssembly>
+    <_SampleProject>Wasm.Console.Node.Sample.csproj</_SampleProject>
+    <_SampleAssembly>Wasm.Console.Node.Sample.dll</_SampleAssembly>
   </PropertyGroup>
 
   <Target Name="RunSample" DependsOnTargets="RunSampleWithNode" />
index cb5584a..3cd0598 100644 (file)
@@ -6,5 +6,5 @@ const { MONO } = await createDotnetRuntime(() => ({
 }));
 
 const app_args = process.argv.slice(2);
-const dllName = "Wasm.Console.Node.ES6.Sample.dll";
+const dllName = "Wasm.Console.Node.Sample.dll";
 await MONO.mono_run_main_and_exit(dllName, app_args);
index a97fd62..29ca6a6 100644 (file)
@@ -10,8 +10,8 @@ ifneq ($(V),)
 DOTNET_MONO_LOG_LEVEL=--setenv=MONO_LOG_LEVEL=debug
 endif
 
-PROJECT_NAME=Wasm.Console.Node.ES6.Sample.csproj
-CONSOLE_DLL=Wasm.Console.Node.ES6.Sample.dll
+PROJECT_NAME=Wasm.Console.Node.Sample.csproj
+CONSOLE_DLL=Wasm.Console.Node.Sample.dll
 MAIN_JS=main.mjs
 
 run: run-console-node
diff --git a/src/mono/sample/wasm/console-v8-cjs/Makefile b/src/mono/sample/wasm/console-v8-cjs/Makefile
deleted file mode 100644 (file)
index b2683b6..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-TOP=../../../../..
-
-include ../wasm.mk
-
-ifneq ($(AOT),)
-override MSBUILD_ARGS+=/p:RunAOTCompilation=true
-endif
-
-ifneq ($(V),)
-DOTNET_MONO_LOG_LEVEL=--setenv=MONO_LOG_LEVEL=debug
-endif
-
-PROJECT_NAME=Wasm.Console.V8.CJS.Sample.csproj
-CONSOLE_DLL=Wasm.Console.V8.CJS.Sample.dll
-MAIN_JS=main.cjs
-
-run: run-console
diff --git a/src/mono/sample/wasm/console-v8-cjs/Program.cs b/src/mono/sample/wasm/console-v8-cjs/Program.cs
deleted file mode 100644 (file)
index 7d959de..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Threading.Tasks;
-
-public class Test
-{
-    public static async Task<int> Main(string[] args)
-    {
-        await Task.Delay(1);
-        Console.WriteLine("Hello World!");
-        for (int i = 0; i < args.Length; i++) {
-            Console.WriteLine($"args[{i}] = {args[i]}");
-        }
-        return 0;
-    }
-}
diff --git a/src/mono/sample/wasm/console-v8-cjs/Wasm.Console.V8.CJS.Sample.csproj b/src/mono/sample/wasm/console-v8-cjs/Wasm.Console.V8.CJS.Sample.csproj
deleted file mode 100644 (file)
index e341502..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-  <PropertyGroup>
-    <WasmCopyAppZipToHelixTestDir Condition="'$(ArchiveTests)' == 'true'">true</WasmCopyAppZipToHelixTestDir>
-    <WasmMainJSPath>main.cjs</WasmMainJSPath>
-    <WasmGenerateRunV8Script>true</WasmGenerateRunV8Script>
-    <WasmEnableES6>false</WasmEnableES6>
-
-    <GenerateRunScriptForSample Condition="'$(ArchiveTests)' == 'true'">true</GenerateRunScriptForSample>
-    <RunScriptCommand>$(ExecXHarnessCmd) wasm test --app=. --engine=V8 --engine-arg=--stack-trace-limit=1000 --js-file=main.cjs --output-directory=$(XHarnessOutput) -- --run $(MSBuildProjectName).dll</RunScriptCommand>
-  </PropertyGroup>
-
-  <PropertyGroup>
-    <_SampleProject>Wasm.Console.V8.CJS.Sample.csproj</_SampleProject>
-    <_SampleAssembly>Wasm.Console.V8.CJS.Sample.dll</_SampleAssembly>
-  </PropertyGroup>
-
-  <Target Name="RunSample" DependsOnTargets="RunSampleWithV8" />
-</Project>
diff --git a/src/mono/sample/wasm/console-v8-cjs/main.cjs b/src/mono/sample/wasm/console-v8-cjs/main.cjs
deleted file mode 100644 (file)
index 5cca184..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-load("./dotnet.js")
-
-const dllName = "Wasm.Console.V8.CJS.Sample.dll";
-const app_args = Array.from(arguments);
-
-async function main() {
-    const { MONO } = await createDotnetRuntime();
-    await MONO.mono_run_main_and_exit(dllName, app_args);
-}
-
-main();
\ No newline at end of file
index 7ceb7d3..1873a79 100644 (file)
@@ -10,8 +10,8 @@ ifneq ($(V),)
 DOTNET_MONO_LOG_LEVEL=--setenv=MONO_LOG_LEVEL=debug
 endif
 
-PROJECT_NAME=Wasm.Console.V8.ES6.Sample.csproj
-CONSOLE_DLL=Wasm.Console.V8.ES6.Sample.dll
+PROJECT_NAME=Wasm.Console.V8.Sample.csproj
+CONSOLE_DLL=Wasm.Console.V8.Sample.dll
 MAIN_JS=v8shim.cjs
 
 run: run-console
@@ -13,8 +13,8 @@
   </ItemGroup>
 
   <PropertyGroup>
-    <_SampleProject>Wasm.Console.V8.ES6.Sample.csproj</_SampleProject>
-    <_SampleAssembly>Wasm.Console.V8.ES6.Sample.dll</_SampleAssembly>
+    <_SampleProject>Wasm.Console.V8.Sample.csproj</_SampleProject>
+    <_SampleAssembly>Wasm.Console.V8.Sample.dll</_SampleAssembly>
   </PropertyGroup>
 
   <Target Name="RunSample" DependsOnTargets="RunSampleWithV8" />
index f6bfd7b..11d9ce8 100644 (file)
@@ -1,6 +1,6 @@
 import createDotnetRuntime from './dotnet.js'
 
-const dllName = "Wasm.Console.V8.ES6.Sample.dll";
+const dllName = "Wasm.Console.V8.Sample.dll";
 const app_args = Array.from(arguments);
 
 async function main() {
index 0509428..62241ac 100644 (file)
@@ -163,11 +163,11 @@ The samples in `src/mono/sample/wasm` can be build and run like this:
 
 * console Hello world sample
 
-`dotnet build /t:RunSample console-v8-cjs/Wasm.Console.V8.CJS.Sample.csproj`
+`dotnet build /t:RunSample console-v8-es6/Wasm.Console.V8.Sample.csproj`
 
 * browser TestMeaning sample
 
-`dotnet build /t:RunSample browser/Wasm.Browser.CJS.Sample.csproj`
+`dotnet build /t:RunSample browser/Wasm.Browser.Sample.csproj`
 
 To build and run the samples with AOT, add `/p:RunAOTCompilation=true` to the above command lines.
 
index df444e4..5f312ad 100644 (file)
@@ -32,7 +32,7 @@ Implementation:
     - *after* any of the wasm build targets, use `AfterTargets="WasmBuildApp"` on that target
 - Avoid depending on this target, because it is available only when the workload is installed. Use `$(WasmNativeWorkload)` to check if it is installed.
 
-- `WasmEnableES6==false` will cause native re-link and produce `dotnet.js` as CJS module. When `Module.disableDotnet6Compatibility` is set it would not pollute global namespace.
+- When `Module.disableDotnet6Compatibility` is set it would not pollute global namespace.
 
 ## `Publish`
 
index b20f012..c4d0673 100644 (file)
       <WasmBuildNative Condition="'$(RunAOTCompilation)' == 'true' and '$(RunAOTCompilationAfterBuild)' == 'true'">true</WasmBuildNative>
 
       <WasmBuildNative Condition="'$(WasmBuildNative)' == '' and @(NativeFileReference->Count()) > 0" >true</WasmBuildNative>
-      <!-- need to re-link dotnet.js when not targeting ES6 -->
-      <WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(WasmEnableES6)' == 'false'" >true</WasmBuildNative>
 
       <WasmBuildNative Condition="'$(WasmBuildNative)' == ''">false</WasmBuildNative>
     </PropertyGroup>
       <!-- AOT==true overrides WasmBuildNative -->
       <WasmBuildNative Condition="'$(RunAOTCompilation)' == 'true'">true</WasmBuildNative>
       <WasmBuildNative Condition="'$(WasmBuildNative)' == '' and @(NativeFileReference->Count()) > 0" >true</WasmBuildNative>
-      <!-- need to re-link dotnet.js when not targeting ES6 -->
-      <WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(WasmEnableES6)' == 'false'" >true</WasmBuildNative>
 
       <!-- not aot, not trimmed app, no reason to relink -->
       <WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(PublishTrimmed)' != 'true'">false</WasmBuildNative>
 
       <_EmccCommonFlags Include="$(_DefaultEmccFlags)" />
       <_EmccCommonFlags Include="$(EmccFlags)" />
-      <_EmccCommonFlags Include="-s EXPORT_ES6=1"                   Condition="'$(WasmEnableES6)' != 'false'" />
+      <_EmccCommonFlags Include="-s EXPORT_ES6=1" />
       <_EmccCommonFlags Include="-g"                                Condition="'$(WasmNativeStrip)' == 'false'" />
       <_EmccCommonFlags Include="-v"                                Condition="'$(EmccVerbose)' != 'false'" />
       <_EmccCommonFlags Include="-s DISABLE_EXCEPTION_CATCHING=0"   Condition="'$(WasmExceptionHandling)' == 'false'" />
       <JSFileType Include="extpost.js" Kind="extern-post-js" />
 
       <_WasmExtraJSFile Include="$(_WasmRuntimePackSrcDir)\*.%(JSFileType.Identity)"     Kind="%(JSFileType.Kind)" />
-      <_WasmExtraJSFile Include="$(_WasmRuntimePackSrcDir)\cjs\*.%(JSFileType.Identity)" Kind="%(JSFileType.Kind)" Condition="'$(WasmEnableES6)' == 'false'" />
-      <_WasmExtraJSFile Include="$(_WasmRuntimePackSrcDir)\es6\*.%(JSFileType.Identity)" Kind="%(JSFileType.Kind)" Condition="'$(WasmEnableES6)' != 'false'" />
+      <_WasmExtraJSFile Include="$(_WasmRuntimePackSrcDir)\es6\*.%(JSFileType.Identity)" Kind="%(JSFileType.Kind)" />
 
       <_WasmNativeFileForLinking Include="@(NativeFileReference)" />
 
index 2d2afed..0a03189 100644 (file)
     <WasmAppBuilder
       AppDir="$(WasmAppDir)"
       MainJS="$(WasmMainJSPath)"
-      WasmEnableES6="$(WasmEnableES6)"
       MainHTMLPath="$(WasmMainHTMLPath)"
       Assemblies="@(_WasmAssembliesInternal)"
       MainAssemblyName="$(WasmMainAssemblyFileName)"
index 6c1c96c..04c2fe6 100644 (file)
@@ -582,7 +582,7 @@ namespace DebuggerTests
 
                // Trying to access object as an array
                if (!DotnetObjectId.TryParse(c_obj_id, out var id) || id.Scheme != "object")
-                   Assert.True(false, "Unexpected object id format. Maybe this test is out of sync with the object id format in dotnet.cjs.lib.js?");
+                   Assert.True(false, "Unexpected object id format. Maybe this test is out of sync with the object id format in dotnet.es6.lib.js?");
 
                await GetProperties($"dotnet:array:{id.Value}", expect_ok: false);
            });
index c4b75a6..24c9316 100644 (file)
@@ -924,7 +924,7 @@ namespace DebuggerTests
                 locals = new JArray(locals.Union(locals_internal));
             if (locals_private != null)
                 locals = new JArray(locals.Union(locals_private));
-            // FIXME: Should be done when generating the list in dotnet.cjs.lib.js, but not sure yet
+            // FIXME: Should be done when generating the list in dotnet.es6.lib.js, but not sure yet
             //        whether to remove it, and how to do it correctly.
             if (locals is JArray)
             {
@@ -982,7 +982,7 @@ namespace DebuggerTests
             var locals_internal = frame_props.Value["internalProperties"];
             var locals_private = frame_props.Value["privateProperties"];
 
-            // FIXME: Should be done when generating the list in dotnet.cjs.lib.js, but not sure yet
+            // FIXME: Should be done when generating the list in dotnet.es6.lib.js, but not sure yet
             //        whether to remove it, and how to do it correctly.
             if (locals is JArray)
             {
index fc8456a..3ab56e9 100644 (file)
@@ -19,7 +19,6 @@ module.exports = {
     "ignorePatterns": [
         "node_modules/**/*.*",
         "bin/**/*.*",
-        "cjs/*.js",
         "es6/*.js",
     ],
     "rules": {
diff --git a/src/mono/wasm/runtime/cjs/dotnet.cjs.extpost.js b/src/mono/wasm/runtime/cjs/dotnet.cjs.extpost.js
deleted file mode 100644 (file)
index 703855c..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-var require = require || undefined;
-var __dirname = __dirname || "";
-// if loaded into global namespace and configured with global Module, we will self start in compatibility mode
-const __isWorker = typeof globalThis.importScripts === "function";
-let ENVIRONMENT_IS_GLOBAL = !__isWorker && (typeof globalThis.Module === "object" && globalThis.__dotnet_runtime === __dotnet_runtime);
-if (ENVIRONMENT_IS_GLOBAL) {
-    createDotnetRuntime(() => { return globalThis.Module; }).then((exports) => exports);
-}
-else if (typeof globalThis.__onDotnetRuntimeLoaded === "function") {
-    globalThis.__onDotnetRuntimeLoaded(createDotnetRuntime);
-}
\ No newline at end of file
diff --git a/src/mono/wasm/runtime/cjs/dotnet.cjs.lib.js b/src/mono/wasm/runtime/cjs/dotnet.cjs.lib.js
deleted file mode 100644 (file)
index da7bb6f..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-/* eslint-disable no-undef */
-
-"use strict";
-
-#if USE_PTHREADS
-const usePThreads = `true`;
-const isPThread = `ENVIRONMENT_IS_PTHREAD`;
-#else
-const usePThreads = `false`;
-const isPThread = `false`;
-#endif
-
-const DotnetSupportLib = {
-    $DOTNET: {},
-    // these lines will be placed early on emscripten runtime creation, passing import and export objects into __dotnet_runtime IFFE
-    // we replace implementation of fetch
-    // replacement of require is there for consistency with ES6 code
-    $DOTNET__postset: `
-let __dotnet_replacement_PThread = ${usePThreads} ? {} : undefined;
-if (${usePThreads}) {
-    __dotnet_replacement_PThread.loadWasmModuleToWorker = PThread.loadWasmModuleToWorker;
-    __dotnet_replacement_PThread.threadInitTLS = PThread.threadInitTLS;
-}
-let __dotnet_replacements = {scriptUrl: undefined, fetch: globalThis.fetch, require, updateGlobalBufferAndViews, pthreadReplacements: __dotnet_replacement_PThread};
-if (ENVIRONMENT_IS_NODE) {
-    __dotnet_replacements.requirePromise = Promise.resolve(require);
-}
-let __dotnet_exportedAPI = __dotnet_runtime.__initializeImportsAndExports(
-    { isESM:false, isGlobal:ENVIRONMENT_IS_GLOBAL, isNode:ENVIRONMENT_IS_NODE, isWorker:ENVIRONMENT_IS_WORKER, isShell:ENVIRONMENT_IS_SHELL, isWeb:ENVIRONMENT_IS_WEB, isPThread:${isPThread}, quit_, ExitStatus, requirePromise:Promise.resolve(require)},
-    { mono:MONO, binding:BINDING, internal:INTERNAL, module:Module, marshaled_exports: EXPORTS, marshaled_imports: IMPORTS  },
-    __dotnet_replacements);
-updateGlobalBufferAndViews = __dotnet_replacements.updateGlobalBufferAndViews;
-var fetch = __dotnet_replacements.fetch;
-_scriptDir = __dirname = scriptDirectory = __dotnet_replacements.scriptDirectory;
-if (ENVIRONMENT_IS_NODE) {
-    __dotnet_replacements.requirePromise.then(someRequire => {
-        require = someRequire;
-    });
-}
-var noExitRuntime = __dotnet_replacements.noExitRuntime;
-if (${usePThreads}) {
-    PThread.loadWasmModuleToWorker = __dotnet_replacements.pthreadReplacements.loadWasmModuleToWorker;
-    PThread.threadInitTLS = __dotnet_replacements.pthreadReplacements.threadInitTS;
-}
-`,
-};
-
-// the methods would be visible to EMCC linker
-// --- keep in sync with exports.ts ---
-const linked_functions = [
-    // mini-wasm.c
-    "mono_set_timeout",
-
-    // mini-wasm-debugger.c
-    "mono_wasm_asm_loaded",
-    "mono_wasm_fire_debugger_agent_message",
-    "mono_wasm_debugger_log",
-    "mono_wasm_add_dbg_command_received",
-
-    // mono-threads-wasm.c
-    "schedule_background_exec",
-
-    // driver.c
-    "mono_wasm_invoke_js_blazor",
-    "mono_wasm_trace_logger",
-    "mono_wasm_set_entrypoint_breakpoint",
-    "mono_wasm_event_pipe_early_startup_callback",
-
-    // corebindings.c
-    "mono_wasm_invoke_js_with_args_ref",
-    "mono_wasm_get_object_property_ref",
-    "mono_wasm_set_object_property_ref",
-    "mono_wasm_get_by_index_ref",
-    "mono_wasm_set_by_index_ref",
-    "mono_wasm_get_global_object_ref",
-    "mono_wasm_create_cs_owned_object_ref",
-    "mono_wasm_release_cs_owned_object",
-    "mono_wasm_typed_array_to_array_ref",
-    "mono_wasm_typed_array_copy_to_ref",
-    "mono_wasm_typed_array_from_ref",
-    "mono_wasm_typed_array_copy_from_ref",
-    "mono_wasm_compile_function_ref",
-    "mono_wasm_bind_js_function",
-    "mono_wasm_invoke_bound_function",
-    "mono_wasm_bind_cs_function",
-    "mono_wasm_marshal_promise",
-
-    // pal_icushim_static.c
-    "mono_wasm_load_icu_data",
-    "mono_wasm_get_icudt_name",
-
-    // pal_crypto_webworker.c
-    "dotnet_browser_can_use_subtle_crypto_impl",
-    "dotnet_browser_simple_digest_hash",
-    "dotnet_browser_sign",
-    "dotnet_browser_encrypt_decrypt",
-    "dotnet_browser_derive_bits",
-
-    #if USE_PTHREADS
-    /// mono-threads-wasm.c
-    "mono_wasm_pthread_on_pthread_attached",
-    /// diagnostics_server.c
-    "mono_wasm_diagnostic_server_on_server_thread_created",
-    "mono_wasm_diagnostic_server_on_runtime_server_init",
-    "mono_wasm_diagnostic_server_stream_signal_work_available",
-    #endif
-];
-
-// -- this javascript file is evaluated by emcc during compilation! --
-// we generate simple proxy for each exported function so that emcc will include them in the final output
-for (let linked_function of linked_functions) {
-    const fn_template = `return __dotnet_runtime.__linker_exports.${linked_function}.apply(__dotnet_runtime, arguments)`;
-    DotnetSupportLib[linked_function] = new Function(fn_template);
-}
-
-autoAddDeps(DotnetSupportLib, "$DOTNET");
-mergeInto(LibraryManager.library, DotnetSupportLib);
diff --git a/src/mono/wasm/runtime/cjs/dotnet.cjs.post.js b/src/mono/wasm/runtime/cjs/dotnet.cjs.post.js
deleted file mode 100644 (file)
index 8449395..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-createDotnetRuntime.ready = createDotnetRuntime.ready.then(() => {
-    return __dotnet_exportedAPI;
-})
diff --git a/src/mono/wasm/runtime/cjs/dotnet.cjs.pre.js b/src/mono/wasm/runtime/cjs/dotnet.cjs.pre.js
deleted file mode 100644 (file)
index 19253e1..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-const MONO = {}, BINDING = {}, INTERNAL = {}, IMPORTS = {}, EXPORTS = {};
-if (ENVIRONMENT_IS_GLOBAL) {
-    if (globalThis.Module.ready) {
-        throw new Error("MONO_WASM: Module.ready couldn't be redefined.")
-    }
-    globalThis.Module.ready = Module.ready;
-    Module = createDotnetRuntime = globalThis.Module;
-    if (!createDotnetRuntime.locateFile) createDotnetRuntime.locateFile = createDotnetRuntime.__locateFile = (path) => scriptDirectory + path;
-}
-else if (typeof createDotnetRuntime === "object") {
-    Module = { ready: Module.ready, __undefinedConfig: Object.keys(createDotnetRuntime).length === 1 };
-    Object.assign(Module, createDotnetRuntime);
-    createDotnetRuntime = Module;
-    if (!createDotnetRuntime.locateFile) createDotnetRuntime.locateFile = createDotnetRuntime.__locateFile = (path) => scriptDirectory + path;
-}
-else if (typeof createDotnetRuntime === "function") {
-    Module = { ready: Module.ready };
-    const extension = createDotnetRuntime({ MONO, BINDING, INTERNAL, IMPORTS, EXPORTS, Module })
-    if (extension.ready) {
-        throw new Error("MONO_WASM: Module.ready couldn't be redefined.")
-    }
-    Object.assign(Module, extension);
-    createDotnetRuntime = Module;
-    if (!createDotnetRuntime.locateFile) createDotnetRuntime.locateFile = createDotnetRuntime.__locateFile = (path) => scriptDirectory + path;
-}
-else {
-    throw new Error("MONO_WASM: Can't locate global Module object or moduleFactory callback of createDotnetRuntime function.")
-}
\ No newline at end of file
index 5ad073d..37c6580 100644 (file)
@@ -9,7 +9,6 @@ export function importAndInstantiateMock(mockURL: string): Promise<Mock> {
     if (monoDiagnosticsMock) {
         const mockPrefix = "mock:";
         const scriptURL = mockURL.substring(mockPrefix.length);
-        // revisit this if we ever have a need to mock using CJS, for now we just support ESM
         return import(scriptURL).then((mockModule) => {
             const script = mockModule.default;
             return mock(script, { trace: true });
index d0499e9..7539fa8 100644 (file)
@@ -32,7 +32,7 @@ if (ENVIRONMENT_IS_NODE) {
     __dotnet_replacements.requirePromise = import(/* webpackIgnore: true */'module').then(mod => mod.createRequire(import.meta.url));
 }
 let __dotnet_exportedAPI = __dotnet_runtime.__initializeImportsAndExports(
-    { isESM:true, isGlobal:false, isNode:ENVIRONMENT_IS_NODE, isWorker:ENVIRONMENT_IS_WORKER, isShell:ENVIRONMENT_IS_SHELL, isWeb:ENVIRONMENT_IS_WEB, isPThread:${isPThread}, quit_, ExitStatus, requirePromise:__dotnet_replacements.requirePromise },
+    { isGlobal:false, isNode:ENVIRONMENT_IS_NODE, isWorker:ENVIRONMENT_IS_WORKER, isShell:ENVIRONMENT_IS_SHELL, isWeb:ENVIRONMENT_IS_WEB, isPThread:${isPThread}, quit_, ExitStatus, requirePromise:__dotnet_replacements.requirePromise },
     { mono:MONO, binding:BINDING, internal:INTERNAL, module:Module, marshaled_exports: EXPORTS, marshaled_imports: IMPORTS },
     __dotnet_replacements);
 updateGlobalBufferAndViews = __dotnet_replacements.updateGlobalBufferAndViews;
index b97e106..d9f679a 100644 (file)
@@ -248,7 +248,7 @@ function initializeImportsAndExports(
     }
 
     if (typeof module.disableDotnet6Compatibility === "undefined") {
-        module.disableDotnet6Compatibility = imports.isESM;
+        module.disableDotnet6Compatibility = true;
     }
     // here we expose objects global namespace for tests and backward compatibility
     if (imports.isGlobal || !module.disableDotnet6Compatibility) {
@@ -320,7 +320,7 @@ function initializeImportsAndExports(
 export const __initializeImportsAndExports: any = initializeImportsAndExports; // don't want to export the type
 
 // the methods would be visible to EMCC linker
-// --- keep in sync with dotnet.cjs.lib.js ---
+// --- keep in sync with dotnet.es6.lib.js ---
 const mono_wasm_threads_exports = !MonoWasmThreads ? undefined : {
     // mono-threads-wasm.c
     mono_wasm_pthread_on_pthread_attached,
@@ -331,7 +331,7 @@ const mono_wasm_threads_exports = !MonoWasmThreads ? undefined : {
 };
 
 // the methods would be visible to EMCC linker
-// --- keep in sync with dotnet.cjs.lib.js ---
+// --- keep in sync with dotnet.es6.lib.js ---
 export const __linker_exports: any = {
     // mini-wasm.c
     mono_set_timeout,
index 3a7e97f..5bec05a 100644 (file)
@@ -16,7 +16,6 @@ export let EXPORTS: any;
 export let IMPORTS: any;
 
 // these are imported and re-exported from emscripten internals
-export let ENVIRONMENT_IS_ESM: boolean;
 export let ENVIRONMENT_IS_NODE: boolean;
 export let ENVIRONMENT_IS_SHELL: boolean;
 export let ENVIRONMENT_IS_WEB: boolean;
@@ -36,7 +35,6 @@ export function set_imports_exports(
     EXPORTS = exports.marshaled_exports; // [JSExport]
     IMPORTS = exports.marshaled_imports; // [JSImport]
 
-    ENVIRONMENT_IS_ESM = imports.isESM;
     ENVIRONMENT_IS_NODE = imports.isNode;
     ENVIRONMENT_IS_SHELL = imports.isShell;
     ENVIRONMENT_IS_WEB = imports.isWeb;
index 8267620..b2f2e2a 100644 (file)
@@ -4,23 +4,9 @@ See https://emscripten.org/docs/tools_reference/emcc.html#emcc-pre-js
 
 There are `-extern-pre-js`,`-pre-js`, `-post-js`, `-extern-post-js`.
 In `src\mono\wasm\build\WasmApp.Native.targets` we apply them by file naming convention as: `*.extpre.js`,`*.pre.js`, `*.post.js`, `*.extpost.js`
-- For ES6 with `WasmEnableES6 == true` from `src/es6`folder
-- For CommonJS with `WasmEnableES6 == false` from `src/cjs`folder
 
 In `src\mono\wasm\runtime\CMakeLists.txt` which links only in-tree, we use same mapping explicitly. Right now CommonJS is default.
 
-# dotnet.cjs.extpost.js
-- Is at the end of file but is executed first (1)
-- Applied only when linking CommonJS
-- If `globalThis.Module` exist it takes it and start runtime with it.
-- Otherwise user could still use the `createDotnetRuntime` export or `globalThis.createDotnetRuntime` if it was loaded into global namespace.
-
-# dotnet.cjs.pre.js
-- Executed second (2)
-- Applied only when linking CommonJS
-- Will try to see if it was executed with `globalThis.Module` and if so, it would use it's instance as `Module`. It would preserve emscripten's `Module.ready`
-- Otherwise it would load it would assume it was called via `createDotnetRuntime` export same as described for `dotnet.es6.pre.js` below.
-
 # dotnet.es6.pre.js
 - Executed second (2)
 - Applied only when linking ES6
index abb9082..74f0fef 100644 (file)
@@ -1,6 +1,6 @@
 import Configuration from "consts:configuration";
 import MonoWasmThreads from "consts:monoWasmThreads";
-import { ENVIRONMENT_IS_ESM, ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, ENVIRONMENT_IS_WEB, ENVIRONMENT_IS_WORKER, INTERNAL, Module, runtimeHelpers } from "./imports";
+import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, ENVIRONMENT_IS_WEB, ENVIRONMENT_IS_WORKER, INTERNAL, Module, runtimeHelpers } from "./imports";
 import { afterUpdateGlobalBufferAndViews } from "./memory";
 import { afterLoadWasmModuleToWorker } from "./pthreads/browser";
 import { afterThreadInitTLS } from "./pthreads/worker";
@@ -195,7 +195,7 @@ export function init_polyfills(replacements: EarlyReplacements): void {
 }
 
 export async function init_polyfills_async(): Promise<void> {
-    if (ENVIRONMENT_IS_NODE && ENVIRONMENT_IS_ESM) {
+    if (ENVIRONMENT_IS_NODE) {
         // wait for locateFile setup on NodeJs
         INTERNAL.require = await runtimeHelpers.requirePromise;
         if (globalThis.performance === dummyPerformance) {
@@ -272,31 +272,6 @@ export function detectScriptDirectory(replacements: EarlyReplacements): string {
         // Check worker, not web, since window could be polyfilled
         replacements.scriptUrl = self.location.href;
     }
-    // when ENVIRONMENT_IS_ESM we have scriptUrl from import.meta.url from dotnet.es6.lib.js
-    if (!ENVIRONMENT_IS_ESM) {
-        if (ENVIRONMENT_IS_WEB) {
-            if (
-                (typeof (globalThis.document) === "object") &&
-                (typeof (globalThis.document.createElement) === "function")
-            ) {
-                // blazor injects a module preload link element for dotnet.[version].[sha].js
-                const blazorDotNetJS = Array.from(document.head.getElementsByTagName("link")).filter(elt => elt.rel !== undefined && elt.rel == "modulepreload" && elt.href !== undefined && elt.href.indexOf("dotnet") != -1 && elt.href.indexOf(".js") != -1);
-                if (blazorDotNetJS.length == 1) {
-                    replacements.scriptUrl = blazorDotNetJS[0].href;
-                } else {
-                    const temp = globalThis.document.createElement("a");
-                    temp.href = "dotnet.js";
-                    replacements.scriptUrl = temp.href;
-                }
-            }
-        }
-        if (ENVIRONMENT_IS_NODE) {
-            if (typeof __filename !== "undefined") {
-                // unix vs windows
-                replacements.scriptUrl = __filename;
-            }
-        }
-    }
     if (!replacements.scriptUrl) {
         // probably V8 shell in non ES6
         replacements.scriptUrl = "./dotnet.js";
index a510402..9c6137e 100644 (file)
@@ -74,13 +74,6 @@ const iffeConfig = {
     input: "exports.ts",
     output: [
         {
-            file: nativeBinDir + "/src/cjs/runtime.cjs.iffe.js",
-            name,
-            banner,
-            format,
-            plugins,
-        },
-        {
             file: nativeBinDir + "/src/es6/runtime.es6.iffe.js",
             name,
             banner,
index 9abff18..b909569 100644 (file)
@@ -310,7 +310,6 @@ export function is_nullish<T>(value: T | null | undefined): value is null | unde
 }
 
 export type EarlyImports = {
-    isESM: boolean,
     isGlobal: boolean,
     isNode: boolean,
     isWorker: boolean,
index bf8821c..2eb29cb 100644 (file)
@@ -280,21 +280,8 @@ function applyArguments() {
 }
 
 async function loadDotnet(file) {
-    const cjsExport = new Promise((resolve) => {
-        globalThis.__onDotnetRuntimeLoaded = (createDotnetRuntime) => {
-            delete globalThis.__onDotnetRuntimeLoaded;
-            resolve(createDotnetRuntime);
-        };
-    });
-
     const { default: createDotnetRuntime } = await import(file);
-    if (createDotnetRuntime) {
-        // this runs when loaded module was ES6
-        delete globalThis.__onDotnetRuntimeLoaded;
-        return createDotnetRuntime;
-    }
-
-    return await cjsExport;
+    return createDotnetRuntime;
 }
 
 // this can't be function because of `arguments` scope
index 994f849..8af7a20 100644 (file)
@@ -18,7 +18,6 @@
   <PropertyGroup>
     <ICULibDir Condition="'$(MonoWasmThreads)' != 'true'">$([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'lib'))</ICULibDir>
     <ICULibDir Condition="'$(MonoWasmThreads)' == 'true'">$([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'lib'))</ICULibDir>
-    <WasmEnableES6 Condition="'$(WasmEnableES6)' == ''">true</WasmEnableES6>
     <WasmEnableSIMD Condition="'$(WasmEnableSIMD)' == ''">false</WasmEnableSIMD>
     <FilterSystemTimeZones Condition="'$(FilterSystemTimeZones)' == ''">false</FilterSystemTimeZones>
     <EmccCmd>emcc</EmccCmd>
       <_EmccLinkFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-Wno-pthreads-mem-growth" />
       <_EmccLinkFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-s PTHREAD_POOL_SIZE=4" />
       <_EmccLinkFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-s PTHREAD_POOL_SIZE_STRICT=2" /> <!-- hard error if worker pool is exhausted -->
-      <!--
-      <_EmccLinkFlags Include="-s EXPORT_ES6=1" Condition="'$(WasmEnableES6)' == 'true'" />
-      -->
       <_EmccLinkFlags Include="-s ALLOW_MEMORY_GROWTH=1" />
       <_EmccLinkFlags Include="-s NO_EXIT_RUNTIME=1" />
       <_EmccLinkFlags Include="-s FORCE_FILESYSTEM=1" />
 
       <CMakeConfigurationLinkFlags Condition="'$(Configuration)' == 'Debug'"  >$(CMakeConfigurationEmccFlags)</CMakeConfigurationLinkFlags>
       <CMakeConfigurationLinkFlags Condition="'$(Configuration)' == 'Release'">-O2</CMakeConfigurationLinkFlags>
-      <CMakeConfigurationLinkFlags Condition="'$(WasmEnableES6)' != 'false'">$(CMakeConfigurationLinkFlags) -s EXPORT_ES6=1</CMakeConfigurationLinkFlags>
+      <CMakeConfigurationLinkFlags>$(CMakeConfigurationLinkFlags) -s EXPORT_ES6=1</CMakeConfigurationLinkFlags>
       <CMakeConfigurationLinkFlags Condition="'$(MonoWasmThreads)' == 'true'">$(CMakeConfigurationLinkFlags) -Wno-pthreads-mem-growth</CMakeConfigurationLinkFlags>
       <CMakeConfigurationLinkFlags                                            >$(CMakeConfigurationLinkFlags) --emit-symbol-map</CMakeConfigurationLinkFlags>
 
           DestinationFolder="$(NativeBinDir)src"
           SkipUnchangedFiles="true" />
 
-    <Copy SourceFiles="runtime/cjs/dotnet.cjs.pre.js;
-                       runtime/cjs/dotnet.cjs.lib.js;
-                       runtime/cjs/dotnet.cjs.post.js;
-                       runtime/cjs/dotnet.cjs.extpost.js;"
-          DestinationFolder="$(NativeBinDir)src/cjs"
-          SkipUnchangedFiles="true" />
-
     <Copy SourceFiles="runtime/es6/dotnet.es6.pre.js;
                        runtime/es6/dotnet.es6.lib.js;
                        runtime/es6/dotnet.es6.post.js;"
                              $(_EmccCompileRspPath);
                              $(_EmccLinkRspPath);
                              $(NativeBinDir)src\emcc-props.json" />
-      <WasmSrcFilesCjs Include="$(NativeBinDir)src\cjs\*.js;" />
       <WasmSrcFilesEs6 Include="$(NativeBinDir)src\es6\*.js;" />
       <WasmHeaderFiles Include="$(NativeBinDir)include\wasm\*.h" />
     </ItemGroup>
           DestinationFolder="$(MicrosoftNetCoreAppRuntimePackNativeDir)src"
           SkipUnchangedFiles="true" />
 
-    <Copy SourceFiles="@(WasmSrcFilesCjs)"
-          DestinationFolder="$(MicrosoftNetCoreAppRuntimePackNativeDir)src\cjs"
-          SkipUnchangedFiles="true" />
-
     <Copy SourceFiles="@(WasmSrcFilesEs6)"
           DestinationFolder="$(MicrosoftNetCoreAppRuntimePackNativeDir)src\es6"
           SkipUnchangedFiles="true" />
index 83c1896..38cf0e1 100644 (file)
@@ -23,8 +23,6 @@ public class WasmAppBuilder : Task
     [Required]
     public string? MainJS { get; set; }
 
-    public string? WasmEnableES6 { get; set; }
-
     [Required]
     public string[] Assemblies { get; set; } = Array.Empty<string>();
 
@@ -209,7 +207,7 @@ public class WasmAppBuilder : Task
         }
 
         string packageJsonPath = Path.Combine(AppDir, "package.json");
-        if (WasmEnableES6 != "false" && !File.Exists(packageJsonPath))
+        if (!File.Exists(packageJsonPath))
         {
             var json = @"{ ""type"":""module"" }";
             File.WriteAllText(packageJsonPath, json);