Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] Templates nits #76182

Merged
merged 6 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mono/wasm/Wasm.Build.Tests/WasmTemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void UpdateConsoleMainJs()

mainJsContent = mainJsContent
.Replace(".create()", ".withConsoleForwarding().create()")
.Replace("[\"dotnet\", \"is\", \"great!\"]", "(await import(/* webpackIgnore: true */\"process\")).argv.slice(2)");
.Replace("['dotnet', 'is', 'great!']", "(await import(/* webpackIgnore: true */\"process\")).argv.slice(2)");
maraf marked this conversation as resolved.
Show resolved Hide resolved

File.WriteAllText(mainJsPath, mainJsContent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"generatorVersions": "[1.0.0.0-*)",
"identity": "WebAssembly.Browser",
"name": "WebAssembly Browser App",
"description": "A project template for creating a .NET app that runs on WebAssembly in a browser",
"shortName": "wasmbrowser",
"sourceName": "browser.0",
"preferNameDirectory": true,
Expand Down
10 changes: 5 additions & 5 deletions src/mono/wasm/templates/templates/browser/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

import { dotnet } from './dotnet.js'

const is_browser = typeof window != "undefined";
if (!is_browser) throw new Error(`Expected to be running in a browser`);
const is_browser = typeof window != 'undefined';
if (!is_browser) throw new Error('Expected to be running in a browser');
maraf marked this conversation as resolved.
Show resolved Hide resolved

const { setModuleImports, getAssemblyExports, getConfig, runMainAndExit } = await dotnet
.withDiagnosticTracing(false)
.withApplicationArgumentsFromQuery()
.create();

setModuleImports("main.js", {
setModuleImports('main.js', {
window: {
location: {
href: () => globalThis.window.location.href
Expand All @@ -24,5 +24,5 @@ const exports = await getAssemblyExports(config.mainAssemblyName);
const text = exports.MyClass.Greeting();
console.log(text);

document.getElementById("out").innerHTML = `${text}`;
await runMainAndExit(config.mainAssemblyName, ["dotnet", "is", "great!"]);
document.getElementById('out').innerHTML = text;
await runMainAndExit(config.mainAssemblyName, ['dotnet', 'is', 'great!']);
maraf marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"classifications": [ "Web", "WebAssembly", "Console" ],
"identity": "WebAssembly.Console",
"name": "WebAssembly Console App",
"description": "A project template for creating a .NET app that runs on WebAssembly on Node JS or V8",
"shortName": "wasmconsole",
"sourceName": "console.0",
"preferNameDirectory": true,
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/templates/templates/console/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { setModuleImports, getAssemblyExports, getConfig, runMainAndExit } = awai
.withDiagnosticTracing(false)
.create();

setModuleImports("main.mjs", {
setModuleImports('main.mjs', {
node: {
process: {
version: () => globalThis.process.version
Expand All @@ -23,4 +23,4 @@ const exports = await getAssemblyExports(config.mainAssemblyName);
const text = exports.MyClass.Greeting();
console.log(text);

await runMainAndExit(config.mainAssemblyName, ["dotnet", "is", "great!"]);
await runMainAndExit(config.mainAssemblyName, ['dotnet', 'is', 'great!']);
maraf marked this conversation as resolved.
Show resolved Hide resolved