Skip to content

[browser][coreCLR] TypeScript host skeleton - #119866

Merged
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts
Sep 29, 2025
Merged

[browser][coreCLR] TypeScript host skeleton#119866
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts

Conversation

@pavelsavara

@pavelsavarapavelsavara commented Sep 18, 2025

Copy link
Copy Markdown
Member

TypeScript + RolllupJS

Goal of this PR is to replace previously merged generated .js with the TS source and necessary compiler+bundler tooling.
Another goal is to produce minified and mangled (small) Release versions of said files.
This is mangled + beautified version of Rollup output from this PR

Rollup

  • minificable cross JS module exchange of functions - cross-module.ts
  • minificable sharing of JS symbols across emscripten libraries - cross-linked.ts
  • dotnetUpdateModuleInternals + dotnetTabulateXXX/expandXXX allow the modules to exchange functions on known index in an array, rather than by symbol name. That makes it possible to JS mangle the symbol.
  • we want to have some symbols same across all modules, they are in reserved const of rollup.config.defines.js

Emscripten linker

  • Emscripten linker executes (our) JS libraries at link time and calls toString on the instantiated functions.
  • It's terrible and it breaks closures. It's by Emscripten design.
  • To deal with that we can't mangle symbol names that leak out of our closure into emscripten closure
  • Symbols that leak into common closure with emscripten have dotnet prefix
  • Functions callable from C are also linked this way, they are trimmable by emscripten linker. They have SystemJS_ or SystemInteropJS_ prefix
  • in libBrowserHost.footer.js we copy the whole rollup function closure and do take binding at runtime for BrowserHost_ functions callable from C
  • in libSystem.Native.Browser.footer.js we install common symbols into emscripten closure from exports.cross

Loader - dotnet.js

  • JS host builder + configuration merge
  • dotnet.boot.js config loading
  • fetchDll -> registerDllBytes -> external_assembly_probe/BrowserHost_ExternalAssemblyProbe
  • BrowserHost_ExecuteAssembly -> coreclr_execute_assembly -> BrowserHost_ResolveMain/BrowserHost_RejectMain
  • emscripen is responsible for .wasm loading, but we need to change it later so that we handle the fingerprinted name and pre-fetch
  • we are missing some Mono features still: re-try, throttling, blazor libraries, progress reporting, ICU loader, load only mode
  • host builder is missing: proper exit implementation, unhandled exception registration and some of the internal testing helpers
  • logging is missing condition inlining via rollup
  • polyfills are simplified to match ecosystem development
  • V8 polyfills incomplete: process
  • fetchLike polyfill for nodeJS and V8 to work with host file system
  • PromiseCompletionSource like TaskCompletionSource but for JS
  • runtimeList is registration of the runtime instance into globalThis. There could be multiple dotnet VMs on the same page.

BrowserHost

  • public JS API for memory operations, run, exit, env variables
  • this part of the host brings non-trimmable JS closure. It's ok because those are public JS APIs and we can't trim them anyway.
  • exit implementation is naive, abort registration is missing
  • pass host properties like TPA via env variables for now

System.Native.Browser

  • implements SystemJS_RandomBytes callable from C and trimmable.
  • it will contain Timers, ThreadPool and Finalizer support later

System.Runtime.InteropServices.JavaScript.Native

  • contains stub for SystemInteropJS_InvokeJSImportST and will contain more JS interop related C callable function later

dotnet.runtime.js

  • is empty at the moment bu will contain JS part of JS interop later
  • it could also contain other larger pieces of JS which we don't want in dotnet.js loader or untrimmable parts of dotnet.native.js

Contributes to #119685
Contributes to #113067

@pavelsavarapavelsavara added this to the 11.0.0 milestone Sep 18, 2025
@pavelsavarapavelsavara self-assigned this Sep 18, 2025
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Sep 18, 2025
@pavelsavara
pavelsavaraforce-pushed the browser_host_ts branch 2 times, most recently from b45b9a5 to 10bf161CompareSeptember 22, 2025 16:05
@dotnet-policy-servicedotnet-policy-serviceBot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 22, 2025
@pavelsavarapavelsavara changed the title [browser][coreCLR] TypeScript host[browser][coreCLR] TypeScript host skeletonSep 25, 2025
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
@pavelsavara
pavelsavara marked this pull request as ready for review September 25, 2025 14:03
CopilotAI review requested due to automatic review settings September 25, 2025 14:03

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces previously generated JavaScript files with TypeScript source code and sets up a complete build toolchain using TypeScript and Rollup. The goal is to produce both readable debug versions and minified release versions of the JavaScript runtime files for the browser CoreCLR host.

Key changes include:

  • Complete replacement of hand-written JavaScript with TypeScript source code
  • Implementation of Rollup.js-based build system with TypeScript compilation
  • Introduction of cross-module symbol sharing system to enable JavaScript minification
  • Renaming of C functions and JavaScript functions to use consistent net and BrowserHost_ prefixes

Reviewed Changes

Copilot reviewed 56 out of 58 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
src/native/tsconfig.jsonUpdates TypeScript target from ES2018 to ES2020
src/native/rollup.stub.jsRemoves temporary stub implementation
src/native/rollup.config.plugins.jsAdds Rollup plugins for minification, source maps, and build optimization
src/native/rollup.config.jsMain Rollup configuration defining all build targets
src/native/rollup.config.defines.jsDefines build constants and reserved symbol names
src/native/package.jsonUpdates dependencies to newer versions
src/native/libs/Common/JavaScript/*Implements shared cross-module communication system
src/native/libs/System.Native.Browser/*TypeScript implementation of native browser functionality
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/*TypeScript implementation of JS interop layer
src/native/corehost/browserhost/*TypeScript implementation of browser host and loader
src/native/corehost/browserhost/browserhost.cppRenames C functions to use BrowserHost_ prefix

Comment threadsrc/native/rollup.config.plugins.js
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
pavelsavaraand others added 2 commits September 25, 2025 16:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@SingleAccretionSingleAccretion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on naming and documentation for the cross-module stuff. I am still to go through the Emscripten integration code.

Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
Comment threadsrc/native/corehost/browserhost/host/memory.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/logging.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js Outdated

@radekdoulikradekdoulik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, besides the other comments.

I think it would be great to document the cross-module concept and also the general library structure somewhere in the docs/. Doesn't need to be in this PR.

- unified names
- uses ambient values in emscripten closure
- uses it's own copy in loader and interop JS modules
- unify dotnetSetInternals and dotnetUpdateAllInternals to dotnetUpdateInternals
- rename tabulate* and expand* functions to *ToTable *FromTable
- rename dotnetUpdateModuleInternals to dotnetUpdateInternalsSubscriber
- moved memory and string utils there
- so that SystemJS_GetLocaleInfo could use them
- without creating dependency cycle
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/ba-g CI timeout in WBT

@pavelsavara
pavelsavara merged commit 97a78d3 into dotnet:mainSep 29, 2025
160 of 162 checks passed
@pavelsavara
pavelsavara deleted the browser_host_ts branch September 29, 2025 17:50
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Oct 30, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Hostlinkable-frameworkIssues associated with delivering a linker friendly frameworkos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@pavelsavara@radekdoulik@maraf@AaronRobinsonMSFT@SingleAccretion
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
[browser][coreCLR] TypeScript host skeleton by pavelsavara · Pull Request #119866 · dotnet/runtime · GitHub
Skip to content

[browser][coreCLR] TypeScript host skeleton - #119866

Merged
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts
Sep 29, 2025
Merged

[browser][coreCLR] TypeScript host skeleton#119866
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts

Conversation

@pavelsavara

@pavelsavarapavelsavara commented Sep 18, 2025

Copy link
Copy Markdown
Member

TypeScript + RolllupJS

Goal of this PR is to replace previously merged generated .js with the TS source and necessary compiler+bundler tooling.
Another goal is to produce minified and mangled (small) Release versions of said files.
This is mangled + beautified version of Rollup output from this PR

Rollup

  • minificable cross JS module exchange of functions - cross-module.ts
  • minificable sharing of JS symbols across emscripten libraries - cross-linked.ts
  • dotnetUpdateModuleInternals + dotnetTabulateXXX/expandXXX allow the modules to exchange functions on known index in an array, rather than by symbol name. That makes it possible to JS mangle the symbol.
  • we want to have some symbols same across all modules, they are in reserved const of rollup.config.defines.js

Emscripten linker

  • Emscripten linker executes (our) JS libraries at link time and calls toString on the instantiated functions.
  • It's terrible and it breaks closures. It's by Emscripten design.
  • To deal with that we can't mangle symbol names that leak out of our closure into emscripten closure
  • Symbols that leak into common closure with emscripten have dotnet prefix
  • Functions callable from C are also linked this way, they are trimmable by emscripten linker. They have SystemJS_ or SystemInteropJS_ prefix
  • in libBrowserHost.footer.js we copy the whole rollup function closure and do take binding at runtime for BrowserHost_ functions callable from C
  • in libSystem.Native.Browser.footer.js we install common symbols into emscripten closure from exports.cross

Loader - dotnet.js

  • JS host builder + configuration merge
  • dotnet.boot.js config loading
  • fetchDll -> registerDllBytes -> external_assembly_probe/BrowserHost_ExternalAssemblyProbe
  • BrowserHost_ExecuteAssembly -> coreclr_execute_assembly -> BrowserHost_ResolveMain/BrowserHost_RejectMain
  • emscripen is responsible for .wasm loading, but we need to change it later so that we handle the fingerprinted name and pre-fetch
  • we are missing some Mono features still: re-try, throttling, blazor libraries, progress reporting, ICU loader, load only mode
  • host builder is missing: proper exit implementation, unhandled exception registration and some of the internal testing helpers
  • logging is missing condition inlining via rollup
  • polyfills are simplified to match ecosystem development
  • V8 polyfills incomplete: process
  • fetchLike polyfill for nodeJS and V8 to work with host file system
  • PromiseCompletionSource like TaskCompletionSource but for JS
  • runtimeList is registration of the runtime instance into globalThis. There could be multiple dotnet VMs on the same page.

BrowserHost

  • public JS API for memory operations, run, exit, env variables
  • this part of the host brings non-trimmable JS closure. It's ok because those are public JS APIs and we can't trim them anyway.
  • exit implementation is naive, abort registration is missing
  • pass host properties like TPA via env variables for now

System.Native.Browser

  • implements SystemJS_RandomBytes callable from C and trimmable.
  • it will contain Timers, ThreadPool and Finalizer support later

System.Runtime.InteropServices.JavaScript.Native

  • contains stub for SystemInteropJS_InvokeJSImportST and will contain more JS interop related C callable function later

dotnet.runtime.js

  • is empty at the moment bu will contain JS part of JS interop later
  • it could also contain other larger pieces of JS which we don't want in dotnet.js loader or untrimmable parts of dotnet.native.js

Contributes to #119685
Contributes to #113067

@pavelsavarapavelsavara added this to the 11.0.0 milestone Sep 18, 2025
@pavelsavarapavelsavara self-assigned this Sep 18, 2025
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Sep 18, 2025
@pavelsavara
pavelsavaraforce-pushed the browser_host_ts branch 2 times, most recently from b45b9a5 to 10bf161CompareSeptember 22, 2025 16:05
@dotnet-policy-servicedotnet-policy-serviceBot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 22, 2025
@pavelsavarapavelsavara changed the title [browser][coreCLR] TypeScript host[browser][coreCLR] TypeScript host skeletonSep 25, 2025
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
@pavelsavara
pavelsavara marked this pull request as ready for review September 25, 2025 14:03
CopilotAI review requested due to automatic review settings September 25, 2025 14:03

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces previously generated JavaScript files with TypeScript source code and sets up a complete build toolchain using TypeScript and Rollup. The goal is to produce both readable debug versions and minified release versions of the JavaScript runtime files for the browser CoreCLR host.

Key changes include:

  • Complete replacement of hand-written JavaScript with TypeScript source code
  • Implementation of Rollup.js-based build system with TypeScript compilation
  • Introduction of cross-module symbol sharing system to enable JavaScript minification
  • Renaming of C functions and JavaScript functions to use consistent net and BrowserHost_ prefixes

Reviewed Changes

Copilot reviewed 56 out of 58 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
src/native/tsconfig.jsonUpdates TypeScript target from ES2018 to ES2020
src/native/rollup.stub.jsRemoves temporary stub implementation
src/native/rollup.config.plugins.jsAdds Rollup plugins for minification, source maps, and build optimization
src/native/rollup.config.jsMain Rollup configuration defining all build targets
src/native/rollup.config.defines.jsDefines build constants and reserved symbol names
src/native/package.jsonUpdates dependencies to newer versions
src/native/libs/Common/JavaScript/*Implements shared cross-module communication system
src/native/libs/System.Native.Browser/*TypeScript implementation of native browser functionality
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/*TypeScript implementation of JS interop layer
src/native/corehost/browserhost/*TypeScript implementation of browser host and loader
src/native/corehost/browserhost/browserhost.cppRenames C functions to use BrowserHost_ prefix

Comment threadsrc/native/rollup.config.plugins.js
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
pavelsavaraand others added 2 commits September 25, 2025 16:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@SingleAccretionSingleAccretion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on naming and documentation for the cross-module stuff. I am still to go through the Emscripten integration code.

Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
Comment threadsrc/native/corehost/browserhost/host/memory.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/logging.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js Outdated

@radekdoulikradekdoulik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, besides the other comments.

I think it would be great to document the cross-module concept and also the general library structure somewhere in the docs/. Doesn't need to be in this PR.

- unified names
- uses ambient values in emscripten closure
- uses it's own copy in loader and interop JS modules
- unify dotnetSetInternals and dotnetUpdateAllInternals to dotnetUpdateInternals
- rename tabulate* and expand* functions to *ToTable *FromTable
- rename dotnetUpdateModuleInternals to dotnetUpdateInternalsSubscriber
- moved memory and string utils there
- so that SystemJS_GetLocaleInfo could use them
- without creating dependency cycle
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/ba-g CI timeout in WBT

@pavelsavara
pavelsavara merged commit 97a78d3 into dotnet:mainSep 29, 2025
160 of 162 checks passed
@pavelsavara
pavelsavara deleted the browser_host_ts branch September 29, 2025 17:50
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Oct 30, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Hostlinkable-frameworkIssues associated with delivering a linker friendly frameworkos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@pavelsavara@radekdoulik@maraf@AaronRobinsonMSFT@SingleAccretion
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [browser][coreCLR] TypeScript host skeleton by pavelsavara · Pull Request #119866 · dotnet/runtime · GitHub
Skip to content

[browser][coreCLR] TypeScript host skeleton - #119866

Merged
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts
Sep 29, 2025
Merged

[browser][coreCLR] TypeScript host skeleton#119866
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts

Conversation

@pavelsavara

@pavelsavarapavelsavara commented Sep 18, 2025

Copy link
Copy Markdown
Member

TypeScript + RolllupJS

Goal of this PR is to replace previously merged generated .js with the TS source and necessary compiler+bundler tooling.
Another goal is to produce minified and mangled (small) Release versions of said files.
This is mangled + beautified version of Rollup output from this PR

Rollup

  • minificable cross JS module exchange of functions - cross-module.ts
  • minificable sharing of JS symbols across emscripten libraries - cross-linked.ts
  • dotnetUpdateModuleInternals + dotnetTabulateXXX/expandXXX allow the modules to exchange functions on known index in an array, rather than by symbol name. That makes it possible to JS mangle the symbol.
  • we want to have some symbols same across all modules, they are in reserved const of rollup.config.defines.js

Emscripten linker

  • Emscripten linker executes (our) JS libraries at link time and calls toString on the instantiated functions.
  • It's terrible and it breaks closures. It's by Emscripten design.
  • To deal with that we can't mangle symbol names that leak out of our closure into emscripten closure
  • Symbols that leak into common closure with emscripten have dotnet prefix
  • Functions callable from C are also linked this way, they are trimmable by emscripten linker. They have SystemJS_ or SystemInteropJS_ prefix
  • in libBrowserHost.footer.js we copy the whole rollup function closure and do take binding at runtime for BrowserHost_ functions callable from C
  • in libSystem.Native.Browser.footer.js we install common symbols into emscripten closure from exports.cross

Loader - dotnet.js

  • JS host builder + configuration merge
  • dotnet.boot.js config loading
  • fetchDll -> registerDllBytes -> external_assembly_probe/BrowserHost_ExternalAssemblyProbe
  • BrowserHost_ExecuteAssembly -> coreclr_execute_assembly -> BrowserHost_ResolveMain/BrowserHost_RejectMain
  • emscripen is responsible for .wasm loading, but we need to change it later so that we handle the fingerprinted name and pre-fetch
  • we are missing some Mono features still: re-try, throttling, blazor libraries, progress reporting, ICU loader, load only mode
  • host builder is missing: proper exit implementation, unhandled exception registration and some of the internal testing helpers
  • logging is missing condition inlining via rollup
  • polyfills are simplified to match ecosystem development
  • V8 polyfills incomplete: process
  • fetchLike polyfill for nodeJS and V8 to work with host file system
  • PromiseCompletionSource like TaskCompletionSource but for JS
  • runtimeList is registration of the runtime instance into globalThis. There could be multiple dotnet VMs on the same page.

BrowserHost

  • public JS API for memory operations, run, exit, env variables
  • this part of the host brings non-trimmable JS closure. It's ok because those are public JS APIs and we can't trim them anyway.
  • exit implementation is naive, abort registration is missing
  • pass host properties like TPA via env variables for now

System.Native.Browser

  • implements SystemJS_RandomBytes callable from C and trimmable.
  • it will contain Timers, ThreadPool and Finalizer support later

System.Runtime.InteropServices.JavaScript.Native

  • contains stub for SystemInteropJS_InvokeJSImportST and will contain more JS interop related C callable function later

dotnet.runtime.js

  • is empty at the moment bu will contain JS part of JS interop later
  • it could also contain other larger pieces of JS which we don't want in dotnet.js loader or untrimmable parts of dotnet.native.js

Contributes to #119685
Contributes to #113067

@pavelsavarapavelsavara added this to the 11.0.0 milestone Sep 18, 2025
@pavelsavarapavelsavara self-assigned this Sep 18, 2025
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Sep 18, 2025
@pavelsavara
pavelsavaraforce-pushed the browser_host_ts branch 2 times, most recently from b45b9a5 to 10bf161CompareSeptember 22, 2025 16:05
@dotnet-policy-servicedotnet-policy-serviceBot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 22, 2025
@pavelsavarapavelsavara changed the title [browser][coreCLR] TypeScript host[browser][coreCLR] TypeScript host skeletonSep 25, 2025
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
@pavelsavara
pavelsavara marked this pull request as ready for review September 25, 2025 14:03
CopilotAI review requested due to automatic review settings September 25, 2025 14:03

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces previously generated JavaScript files with TypeScript source code and sets up a complete build toolchain using TypeScript and Rollup. The goal is to produce both readable debug versions and minified release versions of the JavaScript runtime files for the browser CoreCLR host.

Key changes include:

  • Complete replacement of hand-written JavaScript with TypeScript source code
  • Implementation of Rollup.js-based build system with TypeScript compilation
  • Introduction of cross-module symbol sharing system to enable JavaScript minification
  • Renaming of C functions and JavaScript functions to use consistent net and BrowserHost_ prefixes

Reviewed Changes

Copilot reviewed 56 out of 58 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
src/native/tsconfig.jsonUpdates TypeScript target from ES2018 to ES2020
src/native/rollup.stub.jsRemoves temporary stub implementation
src/native/rollup.config.plugins.jsAdds Rollup plugins for minification, source maps, and build optimization
src/native/rollup.config.jsMain Rollup configuration defining all build targets
src/native/rollup.config.defines.jsDefines build constants and reserved symbol names
src/native/package.jsonUpdates dependencies to newer versions
src/native/libs/Common/JavaScript/*Implements shared cross-module communication system
src/native/libs/System.Native.Browser/*TypeScript implementation of native browser functionality
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/*TypeScript implementation of JS interop layer
src/native/corehost/browserhost/*TypeScript implementation of browser host and loader
src/native/corehost/browserhost/browserhost.cppRenames C functions to use BrowserHost_ prefix

Comment threadsrc/native/rollup.config.plugins.js
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
pavelsavaraand others added 2 commits September 25, 2025 16:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@SingleAccretionSingleAccretion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on naming and documentation for the cross-module stuff. I am still to go through the Emscripten integration code.

Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
Comment threadsrc/native/corehost/browserhost/host/memory.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/logging.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js Outdated

@radekdoulikradekdoulik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, besides the other comments.

I think it would be great to document the cross-module concept and also the general library structure somewhere in the docs/. Doesn't need to be in this PR.

- unified names
- uses ambient values in emscripten closure
- uses it's own copy in loader and interop JS modules
- unify dotnetSetInternals and dotnetUpdateAllInternals to dotnetUpdateInternals
- rename tabulate* and expand* functions to *ToTable *FromTable
- rename dotnetUpdateModuleInternals to dotnetUpdateInternalsSubscriber
- moved memory and string utils there
- so that SystemJS_GetLocaleInfo could use them
- without creating dependency cycle
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/ba-g CI timeout in WBT

@pavelsavara
pavelsavara merged commit 97a78d3 into dotnet:mainSep 29, 2025
160 of 162 checks passed
@pavelsavara
pavelsavara deleted the browser_host_ts branch September 29, 2025 17:50
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Oct 30, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Hostlinkable-frameworkIssues associated with delivering a linker friendly frameworkos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@pavelsavara@radekdoulik@maraf@AaronRobinsonMSFT@SingleAccretion
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [browser][coreCLR] TypeScript host skeleton by pavelsavara · Pull Request #119866 · dotnet/runtime · GitHub
Skip to content

[browser][coreCLR] TypeScript host skeleton - #119866

Merged
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts
Sep 29, 2025
Merged

[browser][coreCLR] TypeScript host skeleton#119866
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts

Conversation

@pavelsavara

@pavelsavarapavelsavara commented Sep 18, 2025

Copy link
Copy Markdown
Member

TypeScript + RolllupJS

Goal of this PR is to replace previously merged generated .js with the TS source and necessary compiler+bundler tooling.
Another goal is to produce minified and mangled (small) Release versions of said files.
This is mangled + beautified version of Rollup output from this PR

Rollup

  • minificable cross JS module exchange of functions - cross-module.ts
  • minificable sharing of JS symbols across emscripten libraries - cross-linked.ts
  • dotnetUpdateModuleInternals + dotnetTabulateXXX/expandXXX allow the modules to exchange functions on known index in an array, rather than by symbol name. That makes it possible to JS mangle the symbol.
  • we want to have some symbols same across all modules, they are in reserved const of rollup.config.defines.js

Emscripten linker

  • Emscripten linker executes (our) JS libraries at link time and calls toString on the instantiated functions.
  • It's terrible and it breaks closures. It's by Emscripten design.
  • To deal with that we can't mangle symbol names that leak out of our closure into emscripten closure
  • Symbols that leak into common closure with emscripten have dotnet prefix
  • Functions callable from C are also linked this way, they are trimmable by emscripten linker. They have SystemJS_ or SystemInteropJS_ prefix
  • in libBrowserHost.footer.js we copy the whole rollup function closure and do take binding at runtime for BrowserHost_ functions callable from C
  • in libSystem.Native.Browser.footer.js we install common symbols into emscripten closure from exports.cross

Loader - dotnet.js

  • JS host builder + configuration merge
  • dotnet.boot.js config loading
  • fetchDll -> registerDllBytes -> external_assembly_probe/BrowserHost_ExternalAssemblyProbe
  • BrowserHost_ExecuteAssembly -> coreclr_execute_assembly -> BrowserHost_ResolveMain/BrowserHost_RejectMain
  • emscripen is responsible for .wasm loading, but we need to change it later so that we handle the fingerprinted name and pre-fetch
  • we are missing some Mono features still: re-try, throttling, blazor libraries, progress reporting, ICU loader, load only mode
  • host builder is missing: proper exit implementation, unhandled exception registration and some of the internal testing helpers
  • logging is missing condition inlining via rollup
  • polyfills are simplified to match ecosystem development
  • V8 polyfills incomplete: process
  • fetchLike polyfill for nodeJS and V8 to work with host file system
  • PromiseCompletionSource like TaskCompletionSource but for JS
  • runtimeList is registration of the runtime instance into globalThis. There could be multiple dotnet VMs on the same page.

BrowserHost

  • public JS API for memory operations, run, exit, env variables
  • this part of the host brings non-trimmable JS closure. It's ok because those are public JS APIs and we can't trim them anyway.
  • exit implementation is naive, abort registration is missing
  • pass host properties like TPA via env variables for now

System.Native.Browser

  • implements SystemJS_RandomBytes callable from C and trimmable.
  • it will contain Timers, ThreadPool and Finalizer support later

System.Runtime.InteropServices.JavaScript.Native

  • contains stub for SystemInteropJS_InvokeJSImportST and will contain more JS interop related C callable function later

dotnet.runtime.js

  • is empty at the moment bu will contain JS part of JS interop later
  • it could also contain other larger pieces of JS which we don't want in dotnet.js loader or untrimmable parts of dotnet.native.js

Contributes to #119685
Contributes to #113067

@pavelsavarapavelsavara added this to the 11.0.0 milestone Sep 18, 2025
@pavelsavarapavelsavara self-assigned this Sep 18, 2025
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Sep 18, 2025
@pavelsavara
pavelsavaraforce-pushed the browser_host_ts branch 2 times, most recently from b45b9a5 to 10bf161CompareSeptember 22, 2025 16:05
@dotnet-policy-servicedotnet-policy-serviceBot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 22, 2025
@pavelsavarapavelsavara changed the title [browser][coreCLR] TypeScript host[browser][coreCLR] TypeScript host skeletonSep 25, 2025
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
@pavelsavara
pavelsavara marked this pull request as ready for review September 25, 2025 14:03
CopilotAI review requested due to automatic review settings September 25, 2025 14:03

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces previously generated JavaScript files with TypeScript source code and sets up a complete build toolchain using TypeScript and Rollup. The goal is to produce both readable debug versions and minified release versions of the JavaScript runtime files for the browser CoreCLR host.

Key changes include:

  • Complete replacement of hand-written JavaScript with TypeScript source code
  • Implementation of Rollup.js-based build system with TypeScript compilation
  • Introduction of cross-module symbol sharing system to enable JavaScript minification
  • Renaming of C functions and JavaScript functions to use consistent net and BrowserHost_ prefixes

Reviewed Changes

Copilot reviewed 56 out of 58 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
src/native/tsconfig.jsonUpdates TypeScript target from ES2018 to ES2020
src/native/rollup.stub.jsRemoves temporary stub implementation
src/native/rollup.config.plugins.jsAdds Rollup plugins for minification, source maps, and build optimization
src/native/rollup.config.jsMain Rollup configuration defining all build targets
src/native/rollup.config.defines.jsDefines build constants and reserved symbol names
src/native/package.jsonUpdates dependencies to newer versions
src/native/libs/Common/JavaScript/*Implements shared cross-module communication system
src/native/libs/System.Native.Browser/*TypeScript implementation of native browser functionality
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/*TypeScript implementation of JS interop layer
src/native/corehost/browserhost/*TypeScript implementation of browser host and loader
src/native/corehost/browserhost/browserhost.cppRenames C functions to use BrowserHost_ prefix

Comment threadsrc/native/rollup.config.plugins.js
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
pavelsavaraand others added 2 commits September 25, 2025 16:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@SingleAccretionSingleAccretion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on naming and documentation for the cross-module stuff. I am still to go through the Emscripten integration code.

Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
Comment threadsrc/native/corehost/browserhost/host/memory.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/logging.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js Outdated

@radekdoulikradekdoulik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, besides the other comments.

I think it would be great to document the cross-module concept and also the general library structure somewhere in the docs/. Doesn't need to be in this PR.

- unified names
- uses ambient values in emscripten closure
- uses it's own copy in loader and interop JS modules
- unify dotnetSetInternals and dotnetUpdateAllInternals to dotnetUpdateInternals
- rename tabulate* and expand* functions to *ToTable *FromTable
- rename dotnetUpdateModuleInternals to dotnetUpdateInternalsSubscriber
- moved memory and string utils there
- so that SystemJS_GetLocaleInfo could use them
- without creating dependency cycle
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/ba-g CI timeout in WBT

@pavelsavara
pavelsavara merged commit 97a78d3 into dotnet:mainSep 29, 2025
160 of 162 checks passed
@pavelsavara
pavelsavara deleted the browser_host_ts branch September 29, 2025 17:50
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Oct 30, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Hostlinkable-frameworkIssues associated with delivering a linker friendly frameworkos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@pavelsavara@radekdoulik@maraf@AaronRobinsonMSFT@SingleAccretion
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' [browser][coreCLR] TypeScript host skeleton by pavelsavara · Pull Request #119866 · dotnet/runtime · GitHub
Skip to content

[browser][coreCLR] TypeScript host skeleton - #119866

Merged
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts
Sep 29, 2025
Merged

[browser][coreCLR] TypeScript host skeleton#119866
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts

Conversation

@pavelsavara

@pavelsavarapavelsavara commented Sep 18, 2025

Copy link
Copy Markdown
Member

TypeScript + RolllupJS

Goal of this PR is to replace previously merged generated .js with the TS source and necessary compiler+bundler tooling.
Another goal is to produce minified and mangled (small) Release versions of said files.
This is mangled + beautified version of Rollup output from this PR

Rollup

  • minificable cross JS module exchange of functions - cross-module.ts
  • minificable sharing of JS symbols across emscripten libraries - cross-linked.ts
  • dotnetUpdateModuleInternals + dotnetTabulateXXX/expandXXX allow the modules to exchange functions on known index in an array, rather than by symbol name. That makes it possible to JS mangle the symbol.
  • we want to have some symbols same across all modules, they are in reserved const of rollup.config.defines.js

Emscripten linker

  • Emscripten linker executes (our) JS libraries at link time and calls toString on the instantiated functions.
  • It's terrible and it breaks closures. It's by Emscripten design.
  • To deal with that we can't mangle symbol names that leak out of our closure into emscripten closure
  • Symbols that leak into common closure with emscripten have dotnet prefix
  • Functions callable from C are also linked this way, they are trimmable by emscripten linker. They have SystemJS_ or SystemInteropJS_ prefix
  • in libBrowserHost.footer.js we copy the whole rollup function closure and do take binding at runtime for BrowserHost_ functions callable from C
  • in libSystem.Native.Browser.footer.js we install common symbols into emscripten closure from exports.cross

Loader - dotnet.js

  • JS host builder + configuration merge
  • dotnet.boot.js config loading
  • fetchDll -> registerDllBytes -> external_assembly_probe/BrowserHost_ExternalAssemblyProbe
  • BrowserHost_ExecuteAssembly -> coreclr_execute_assembly -> BrowserHost_ResolveMain/BrowserHost_RejectMain
  • emscripen is responsible for .wasm loading, but we need to change it later so that we handle the fingerprinted name and pre-fetch
  • we are missing some Mono features still: re-try, throttling, blazor libraries, progress reporting, ICU loader, load only mode
  • host builder is missing: proper exit implementation, unhandled exception registration and some of the internal testing helpers
  • logging is missing condition inlining via rollup
  • polyfills are simplified to match ecosystem development
  • V8 polyfills incomplete: process
  • fetchLike polyfill for nodeJS and V8 to work with host file system
  • PromiseCompletionSource like TaskCompletionSource but for JS
  • runtimeList is registration of the runtime instance into globalThis. There could be multiple dotnet VMs on the same page.

BrowserHost

  • public JS API for memory operations, run, exit, env variables
  • this part of the host brings non-trimmable JS closure. It's ok because those are public JS APIs and we can't trim them anyway.
  • exit implementation is naive, abort registration is missing
  • pass host properties like TPA via env variables for now

System.Native.Browser

  • implements SystemJS_RandomBytes callable from C and trimmable.
  • it will contain Timers, ThreadPool and Finalizer support later

System.Runtime.InteropServices.JavaScript.Native

  • contains stub for SystemInteropJS_InvokeJSImportST and will contain more JS interop related C callable function later

dotnet.runtime.js

  • is empty at the moment bu will contain JS part of JS interop later
  • it could also contain other larger pieces of JS which we don't want in dotnet.js loader or untrimmable parts of dotnet.native.js

Contributes to #119685
Contributes to #113067

@pavelsavarapavelsavara added this to the 11.0.0 milestone Sep 18, 2025
@pavelsavarapavelsavara self-assigned this Sep 18, 2025
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Sep 18, 2025
@pavelsavara
pavelsavaraforce-pushed the browser_host_ts branch 2 times, most recently from b45b9a5 to 10bf161CompareSeptember 22, 2025 16:05
@dotnet-policy-servicedotnet-policy-serviceBot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 22, 2025
@pavelsavarapavelsavara changed the title [browser][coreCLR] TypeScript host[browser][coreCLR] TypeScript host skeletonSep 25, 2025
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
@pavelsavara
pavelsavara marked this pull request as ready for review September 25, 2025 14:03
CopilotAI review requested due to automatic review settings September 25, 2025 14:03

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces previously generated JavaScript files with TypeScript source code and sets up a complete build toolchain using TypeScript and Rollup. The goal is to produce both readable debug versions and minified release versions of the JavaScript runtime files for the browser CoreCLR host.

Key changes include:

  • Complete replacement of hand-written JavaScript with TypeScript source code
  • Implementation of Rollup.js-based build system with TypeScript compilation
  • Introduction of cross-module symbol sharing system to enable JavaScript minification
  • Renaming of C functions and JavaScript functions to use consistent net and BrowserHost_ prefixes

Reviewed Changes

Copilot reviewed 56 out of 58 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
src/native/tsconfig.jsonUpdates TypeScript target from ES2018 to ES2020
src/native/rollup.stub.jsRemoves temporary stub implementation
src/native/rollup.config.plugins.jsAdds Rollup plugins for minification, source maps, and build optimization
src/native/rollup.config.jsMain Rollup configuration defining all build targets
src/native/rollup.config.defines.jsDefines build constants and reserved symbol names
src/native/package.jsonUpdates dependencies to newer versions
src/native/libs/Common/JavaScript/*Implements shared cross-module communication system
src/native/libs/System.Native.Browser/*TypeScript implementation of native browser functionality
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/*TypeScript implementation of JS interop layer
src/native/corehost/browserhost/*TypeScript implementation of browser host and loader
src/native/corehost/browserhost/browserhost.cppRenames C functions to use BrowserHost_ prefix

Comment threadsrc/native/rollup.config.plugins.js
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
pavelsavaraand others added 2 commits September 25, 2025 16:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@SingleAccretionSingleAccretion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on naming and documentation for the cross-module stuff. I am still to go through the Emscripten integration code.

Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
Comment threadsrc/native/corehost/browserhost/host/memory.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/logging.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js Outdated

@radekdoulikradekdoulik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, besides the other comments.

I think it would be great to document the cross-module concept and also the general library structure somewhere in the docs/. Doesn't need to be in this PR.

- unified names
- uses ambient values in emscripten closure
- uses it's own copy in loader and interop JS modules
- unify dotnetSetInternals and dotnetUpdateAllInternals to dotnetUpdateInternals
- rename tabulate* and expand* functions to *ToTable *FromTable
- rename dotnetUpdateModuleInternals to dotnetUpdateInternalsSubscriber
- moved memory and string utils there
- so that SystemJS_GetLocaleInfo could use them
- without creating dependency cycle
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/ba-g CI timeout in WBT

@pavelsavara
pavelsavara merged commit 97a78d3 into dotnet:mainSep 29, 2025
160 of 162 checks passed
@pavelsavara
pavelsavara deleted the browser_host_ts branch September 29, 2025 17:50
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Oct 30, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Hostlinkable-frameworkIssues associated with delivering a linker friendly frameworkos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@pavelsavara@radekdoulik@maraf@AaronRobinsonMSFT@SingleAccretion
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [browser][coreCLR] TypeScript host skeleton by pavelsavara · Pull Request #119866 · dotnet/runtime · GitHub
Skip to content

[browser][coreCLR] TypeScript host skeleton - #119866

Merged
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts
Sep 29, 2025
Merged

[browser][coreCLR] TypeScript host skeleton#119866
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts

Conversation

@pavelsavara

@pavelsavarapavelsavara commented Sep 18, 2025

Copy link
Copy Markdown
Member

TypeScript + RolllupJS

Goal of this PR is to replace previously merged generated .js with the TS source and necessary compiler+bundler tooling.
Another goal is to produce minified and mangled (small) Release versions of said files.
This is mangled + beautified version of Rollup output from this PR

Rollup

  • minificable cross JS module exchange of functions - cross-module.ts
  • minificable sharing of JS symbols across emscripten libraries - cross-linked.ts
  • dotnetUpdateModuleInternals + dotnetTabulateXXX/expandXXX allow the modules to exchange functions on known index in an array, rather than by symbol name. That makes it possible to JS mangle the symbol.
  • we want to have some symbols same across all modules, they are in reserved const of rollup.config.defines.js

Emscripten linker

  • Emscripten linker executes (our) JS libraries at link time and calls toString on the instantiated functions.
  • It's terrible and it breaks closures. It's by Emscripten design.
  • To deal with that we can't mangle symbol names that leak out of our closure into emscripten closure
  • Symbols that leak into common closure with emscripten have dotnet prefix
  • Functions callable from C are also linked this way, they are trimmable by emscripten linker. They have SystemJS_ or SystemInteropJS_ prefix
  • in libBrowserHost.footer.js we copy the whole rollup function closure and do take binding at runtime for BrowserHost_ functions callable from C
  • in libSystem.Native.Browser.footer.js we install common symbols into emscripten closure from exports.cross

Loader - dotnet.js

  • JS host builder + configuration merge
  • dotnet.boot.js config loading
  • fetchDll -> registerDllBytes -> external_assembly_probe/BrowserHost_ExternalAssemblyProbe
  • BrowserHost_ExecuteAssembly -> coreclr_execute_assembly -> BrowserHost_ResolveMain/BrowserHost_RejectMain
  • emscripen is responsible for .wasm loading, but we need to change it later so that we handle the fingerprinted name and pre-fetch
  • we are missing some Mono features still: re-try, throttling, blazor libraries, progress reporting, ICU loader, load only mode
  • host builder is missing: proper exit implementation, unhandled exception registration and some of the internal testing helpers
  • logging is missing condition inlining via rollup
  • polyfills are simplified to match ecosystem development
  • V8 polyfills incomplete: process
  • fetchLike polyfill for nodeJS and V8 to work with host file system
  • PromiseCompletionSource like TaskCompletionSource but for JS
  • runtimeList is registration of the runtime instance into globalThis. There could be multiple dotnet VMs on the same page.

BrowserHost

  • public JS API for memory operations, run, exit, env variables
  • this part of the host brings non-trimmable JS closure. It's ok because those are public JS APIs and we can't trim them anyway.
  • exit implementation is naive, abort registration is missing
  • pass host properties like TPA via env variables for now

System.Native.Browser

  • implements SystemJS_RandomBytes callable from C and trimmable.
  • it will contain Timers, ThreadPool and Finalizer support later

System.Runtime.InteropServices.JavaScript.Native

  • contains stub for SystemInteropJS_InvokeJSImportST and will contain more JS interop related C callable function later

dotnet.runtime.js

  • is empty at the moment bu will contain JS part of JS interop later
  • it could also contain other larger pieces of JS which we don't want in dotnet.js loader or untrimmable parts of dotnet.native.js

Contributes to #119685
Contributes to #113067

@pavelsavarapavelsavara added this to the 11.0.0 milestone Sep 18, 2025
@pavelsavarapavelsavara self-assigned this Sep 18, 2025
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Sep 18, 2025
@pavelsavara
pavelsavaraforce-pushed the browser_host_ts branch 2 times, most recently from b45b9a5 to 10bf161CompareSeptember 22, 2025 16:05
@dotnet-policy-servicedotnet-policy-serviceBot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 22, 2025
@pavelsavarapavelsavara changed the title [browser][coreCLR] TypeScript host[browser][coreCLR] TypeScript host skeletonSep 25, 2025
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
@pavelsavara
pavelsavara marked this pull request as ready for review September 25, 2025 14:03
CopilotAI review requested due to automatic review settings September 25, 2025 14:03

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces previously generated JavaScript files with TypeScript source code and sets up a complete build toolchain using TypeScript and Rollup. The goal is to produce both readable debug versions and minified release versions of the JavaScript runtime files for the browser CoreCLR host.

Key changes include:

  • Complete replacement of hand-written JavaScript with TypeScript source code
  • Implementation of Rollup.js-based build system with TypeScript compilation
  • Introduction of cross-module symbol sharing system to enable JavaScript minification
  • Renaming of C functions and JavaScript functions to use consistent net and BrowserHost_ prefixes

Reviewed Changes

Copilot reviewed 56 out of 58 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
src/native/tsconfig.jsonUpdates TypeScript target from ES2018 to ES2020
src/native/rollup.stub.jsRemoves temporary stub implementation
src/native/rollup.config.plugins.jsAdds Rollup plugins for minification, source maps, and build optimization
src/native/rollup.config.jsMain Rollup configuration defining all build targets
src/native/rollup.config.defines.jsDefines build constants and reserved symbol names
src/native/package.jsonUpdates dependencies to newer versions
src/native/libs/Common/JavaScript/*Implements shared cross-module communication system
src/native/libs/System.Native.Browser/*TypeScript implementation of native browser functionality
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/*TypeScript implementation of JS interop layer
src/native/corehost/browserhost/*TypeScript implementation of browser host and loader
src/native/corehost/browserhost/browserhost.cppRenames C functions to use BrowserHost_ prefix

Comment threadsrc/native/rollup.config.plugins.js
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
pavelsavaraand others added 2 commits September 25, 2025 16:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@SingleAccretionSingleAccretion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on naming and documentation for the cross-module stuff. I am still to go through the Emscripten integration code.

Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
Comment threadsrc/native/corehost/browserhost/host/memory.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/logging.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js Outdated

@radekdoulikradekdoulik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, besides the other comments.

I think it would be great to document the cross-module concept and also the general library structure somewhere in the docs/. Doesn't need to be in this PR.

- unified names
- uses ambient values in emscripten closure
- uses it's own copy in loader and interop JS modules
- unify dotnetSetInternals and dotnetUpdateAllInternals to dotnetUpdateInternals
- rename tabulate* and expand* functions to *ToTable *FromTable
- rename dotnetUpdateModuleInternals to dotnetUpdateInternalsSubscriber
- moved memory and string utils there
- so that SystemJS_GetLocaleInfo could use them
- without creating dependency cycle
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/ba-g CI timeout in WBT

@pavelsavara
pavelsavara merged commit 97a78d3 into dotnet:mainSep 29, 2025
160 of 162 checks passed
@pavelsavara
pavelsavara deleted the browser_host_ts branch September 29, 2025 17:50
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Oct 30, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Hostlinkable-frameworkIssues associated with delivering a linker friendly frameworkos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@pavelsavara@radekdoulik@maraf@AaronRobinsonMSFT@SingleAccretion
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); [browser][coreCLR] TypeScript host skeleton by pavelsavara · Pull Request #119866 · dotnet/runtime · GitHub
Skip to content

[browser][coreCLR] TypeScript host skeleton - #119866

Merged
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts
Sep 29, 2025
Merged

[browser][coreCLR] TypeScript host skeleton#119866
pavelsavara merged 43 commits into
dotnet:mainfrom
pavelsavara:browser_host_ts

Conversation

@pavelsavara

@pavelsavarapavelsavara commented Sep 18, 2025

Copy link
Copy Markdown
Member

TypeScript + RolllupJS

Goal of this PR is to replace previously merged generated .js with the TS source and necessary compiler+bundler tooling.
Another goal is to produce minified and mangled (small) Release versions of said files.
This is mangled + beautified version of Rollup output from this PR

Rollup

  • minificable cross JS module exchange of functions - cross-module.ts
  • minificable sharing of JS symbols across emscripten libraries - cross-linked.ts
  • dotnetUpdateModuleInternals + dotnetTabulateXXX/expandXXX allow the modules to exchange functions on known index in an array, rather than by symbol name. That makes it possible to JS mangle the symbol.
  • we want to have some symbols same across all modules, they are in reserved const of rollup.config.defines.js

Emscripten linker

  • Emscripten linker executes (our) JS libraries at link time and calls toString on the instantiated functions.
  • It's terrible and it breaks closures. It's by Emscripten design.
  • To deal with that we can't mangle symbol names that leak out of our closure into emscripten closure
  • Symbols that leak into common closure with emscripten have dotnet prefix
  • Functions callable from C are also linked this way, they are trimmable by emscripten linker. They have SystemJS_ or SystemInteropJS_ prefix
  • in libBrowserHost.footer.js we copy the whole rollup function closure and do take binding at runtime for BrowserHost_ functions callable from C
  • in libSystem.Native.Browser.footer.js we install common symbols into emscripten closure from exports.cross

Loader - dotnet.js

  • JS host builder + configuration merge
  • dotnet.boot.js config loading
  • fetchDll -> registerDllBytes -> external_assembly_probe/BrowserHost_ExternalAssemblyProbe
  • BrowserHost_ExecuteAssembly -> coreclr_execute_assembly -> BrowserHost_ResolveMain/BrowserHost_RejectMain
  • emscripen is responsible for .wasm loading, but we need to change it later so that we handle the fingerprinted name and pre-fetch
  • we are missing some Mono features still: re-try, throttling, blazor libraries, progress reporting, ICU loader, load only mode
  • host builder is missing: proper exit implementation, unhandled exception registration and some of the internal testing helpers
  • logging is missing condition inlining via rollup
  • polyfills are simplified to match ecosystem development
  • V8 polyfills incomplete: process
  • fetchLike polyfill for nodeJS and V8 to work with host file system
  • PromiseCompletionSource like TaskCompletionSource but for JS
  • runtimeList is registration of the runtime instance into globalThis. There could be multiple dotnet VMs on the same page.

BrowserHost

  • public JS API for memory operations, run, exit, env variables
  • this part of the host brings non-trimmable JS closure. It's ok because those are public JS APIs and we can't trim them anyway.
  • exit implementation is naive, abort registration is missing
  • pass host properties like TPA via env variables for now

System.Native.Browser

  • implements SystemJS_RandomBytes callable from C and trimmable.
  • it will contain Timers, ThreadPool and Finalizer support later

System.Runtime.InteropServices.JavaScript.Native

  • contains stub for SystemInteropJS_InvokeJSImportST and will contain more JS interop related C callable function later

dotnet.runtime.js

  • is empty at the moment bu will contain JS part of JS interop later
  • it could also contain other larger pieces of JS which we don't want in dotnet.js loader or untrimmable parts of dotnet.native.js

Contributes to #119685
Contributes to #113067

@pavelsavarapavelsavara added this to the 11.0.0 milestone Sep 18, 2025
@pavelsavarapavelsavara self-assigned this Sep 18, 2025
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Sep 18, 2025
@pavelsavara
pavelsavaraforce-pushed the browser_host_ts branch 2 times, most recently from b45b9a5 to 10bf161CompareSeptember 22, 2025 16:05
@dotnet-policy-servicedotnet-policy-serviceBot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 22, 2025
@pavelsavarapavelsavara changed the title [browser][coreCLR] TypeScript host[browser][coreCLR] TypeScript host skeletonSep 25, 2025
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
@pavelsavara
pavelsavara marked this pull request as ready for review September 25, 2025 14:03
CopilotAI review requested due to automatic review settings September 25, 2025 14:03

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces previously generated JavaScript files with TypeScript source code and sets up a complete build toolchain using TypeScript and Rollup. The goal is to produce both readable debug versions and minified release versions of the JavaScript runtime files for the browser CoreCLR host.

Key changes include:

  • Complete replacement of hand-written JavaScript with TypeScript source code
  • Implementation of Rollup.js-based build system with TypeScript compilation
  • Introduction of cross-module symbol sharing system to enable JavaScript minification
  • Renaming of C functions and JavaScript functions to use consistent net and BrowserHost_ prefixes

Reviewed Changes

Copilot reviewed 56 out of 58 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
src/native/tsconfig.jsonUpdates TypeScript target from ES2018 to ES2020
src/native/rollup.stub.jsRemoves temporary stub implementation
src/native/rollup.config.plugins.jsAdds Rollup plugins for minification, source maps, and build optimization
src/native/rollup.config.jsMain Rollup configuration defining all build targets
src/native/rollup.config.defines.jsDefines build constants and reserved symbol names
src/native/package.jsonUpdates dependencies to newer versions
src/native/libs/Common/JavaScript/*Implements shared cross-module communication system
src/native/libs/System.Native.Browser/*TypeScript implementation of native browser functionality
src/native/libs/System.Runtime.InteropServices.JavaScript.Native/*TypeScript implementation of JS interop layer
src/native/corehost/browserhost/*TypeScript implementation of browser host and loader
src/native/corehost/browserhost/browserhost.cppRenames C functions to use BrowserHost_ prefix

Comment threadsrc/native/rollup.config.plugins.js
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
pavelsavaraand others added 2 commits September 25, 2025 16:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@SingleAccretionSingleAccretion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on naming and documentation for the cross-module stuff. I am still to go through the Emscripten integration code.

Comment threadsrc/native/corehost/browserhost/host/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts Outdated
Comment threadsrc/native/libs/Common/JavaScript/cross-module/index.ts
Comment threadsrc/native/corehost/browserhost/host/memory.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/index.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/logging.ts Outdated
Comment threadsrc/native/corehost/browserhost/loader/run.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/native/cross-linked.ts Outdated
Comment threadsrc/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js Outdated

@radekdoulikradekdoulik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, besides the other comments.

I think it would be great to document the cross-module concept and also the general library structure somewhere in the docs/. Doesn't need to be in this PR.

- unified names
- uses ambient values in emscripten closure
- uses it's own copy in loader and interop JS modules
- unify dotnetSetInternals and dotnetUpdateAllInternals to dotnetUpdateInternals
- rename tabulate* and expand* functions to *ToTable *FromTable
- rename dotnetUpdateModuleInternals to dotnetUpdateInternalsSubscriber
- moved memory and string utils there
- so that SystemJS_GetLocaleInfo could use them
- without creating dependency cycle
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/ba-g CI timeout in WBT

@pavelsavara
pavelsavara merged commit 97a78d3 into dotnet:mainSep 29, 2025
160 of 162 checks passed
@pavelsavara
pavelsavara deleted the browser_host_ts branch September 29, 2025 17:50
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Oct 30, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Hostlinkable-frameworkIssues associated with delivering a linker friendly frameworkos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@pavelsavara@radekdoulik@maraf@AaronRobinsonMSFT@SingleAccretion