-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[browser][coreCLR] TypeScript host skeleton #119866
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
Conversation
b45b9a5
to
10bf161
Compare
2d04313
to
5aa27c3
Compare
3b6c157
to
5ab0c0a
Compare
5ab0c0a
to
47a0b01
Compare
There was a problem hiding this comment.
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
andBrowserHost_
prefixes
Reviewed Changes
Copilot reviewed 56 out of 58 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
src/native/tsconfig.json | Updates TypeScript target from ES2018 to ES2020 |
src/native/rollup.stub.js | Removes temporary stub implementation |
src/native/rollup.config.plugins.js | Adds Rollup plugins for minification, source maps, and build optimization |
src/native/rollup.config.js | Main Rollup configuration defining all build targets |
src/native/rollup.config.defines.js | Defines build constants and reserved symbol names |
src/native/package.json | Updates 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.cpp | Renames C functions to use BrowserHost_ prefix |
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
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.
src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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
/ba-g CI timeout in WBT |
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
cross-module.ts
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.reserved
const ofrollup.config.defines.js
Emscripten linker
toString
on the instantiated functions.dotnet
prefixSystemJS_
orSystemInteropJS_
prefixlibBrowserHost.footer.js
we copy the whole rollup function closure and do take binding at runtime forBrowserHost_
functions callable from ClibSystem.Native.Browser.footer.js
we install common symbols into emscripten closure fromexports.cross
Loader -
dotnet.js
dotnet.boot.js
config loadingfetchDll
->registerDllBytes
->external_assembly_probe
/BrowserHost_ExternalAssemblyProbe
BrowserHost_ExecuteAssembly
->coreclr_execute_assembly
->BrowserHost_ResolveMain
/BrowserHost_RejectMain
process
fetchLike
polyfill for nodeJS and V8 to work with host file systemPromiseCompletionSource
likeTaskCompletionSource
but for JSruntimeList
is registration of the runtime instance intoglobalThis
. There could be multiple dotnet VMs on the same page.BrowserHost
System.Native.Browser
SystemJS_RandomBytes
callable from C and trimmable.System.Runtime.InteropServices.JavaScript.Native
SystemInteropJS_InvokeJSImportST
and will contain more JS interop related C callable function laterdotnet.runtime.js
dotnet.js
loader or untrimmable parts ofdotnet.native.js
Contributes to #119685
Contributes to #113067