Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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/ModuleConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task DownloadProgressFinishes(bool failAssemblyDownload)
);
}

[ConditionalFact(typeof(BuildTestBase), nameof(IsMonoRuntime)), TestCategory("bundler-friendly")]
[Fact, TestCategory("bundler-friendly")]
public async Task OutErrOverrideWorks()
{
Configuration config = Configuration.Debug;
Expand Down
17 changes: 17 additions & 0 deletions src/native/libs/Common/JavaScript/loader/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ export async function createRuntime(downloadOnly: boolean): Promise<any> {
const modulesAfterConfigLoadedPromises: [JsAsset, Promise<any>][] = normalizeCollection(resources.modulesAfterConfigLoaded).map((a) => [a, callLibraryInitializerOnRuntimeConfigLoaded(a)]);
await Promise.all(modulesAfterConfigLoadedPromises.map(([, p]) => p));

// Wire user-provided out/err overrides to Emscripten's print/printErr.
// This must happen before the native module loads so Emscripten picks them up.
if (!Module.out) {
// eslint-disable-next-line no-console
Module.out = console.log.bind(console);
}
if (!Module.err) {
Comment thread
pavelsavara marked this conversation as resolved.
// eslint-disable-next-line no-console
Module.err = console.error.bind(console);
}
if (!Module.print) {
Module.print = Module.out;
}
if (!Module.printErr) {
Comment on lines +40 to +51
Module.printErr = Module.err;
}

// after onConfigLoaded hooks that could install polyfills, our polyfills can be initialized
await initPolyfills();

Expand Down
2 changes: 2 additions & 0 deletions src/native/libs/Common/JavaScript/types/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export type EmscriptenInternals = {
export type EmscriptenModuleInternal = EmscriptenModule & DotnetModuleConfig & {
runtimeKeepalivePush(): void;
runtimeKeepalivePop(): void;
print(message: string): void;
printErr(message: string): void;
instantiateWasm?: InstantiateWasmCallBack;
onAbort?: (reason: any, extraJson?: string) => void;
onExit?: (code: number) => void;
Expand Down