-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[browser][coreCLR] Skeleton for JavaScript host #119683
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
|
Together with #119591
|
97c8a50 to
5d801d7
Compare
36a185e to
552c512
Compare
552c512 to
06aaf6a
Compare
src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props
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.
Pull Request Overview
Establishes the initial skeleton, layout, and build hooks for a JavaScript-based host for CoreCLR targeting browsers and NodeJS, plus supporting JS/TS library scaffolding.
- Introduces placeholder JS libraries for System.JavaScript and System.Runtime.InteropServices.JavaScript and wires them into the Emscripten build.
- Adds a simple browser/NodeJS host (C++ + JS glue) and pipeline/build file updates to include the new components.
- Provides initial TypeScript config, linting setup, and documentation placeholders for the upcoming TS-based implementation.
Reviewed Changes
Copilot reviewed 42 out of 48 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/libs/tsconfig.json | Adds TypeScript compiler configuration for JS/TS libraries. |
| src/native/libs/rollup.config.js | Placeholder rollup config; currently throws not-implemented (build stub). |
| src/native/libs/package.json | Adds npm metadata and devDependencies for rollup/TS/eslint build tooling. |
| src/native/libs/System.Runtime.InteropServices.JavaScript/libSystem.Runtime.InteropServices.JavaScript.js | Dummy JS interop library for Emscripten; exports interop entrypoints and initialization hooks. |
| src/native/libs/System.Runtime.InteropServices.JavaScript/entrypoints.c | C entrypoints mapping to JS implementations for P/Invoke resolution. |
| src/native/libs/System.Runtime.InteropServices.JavaScript/ReadMe.md | Documentation stub for the interop library. |
| src/native/libs/System.Runtime.InteropServices.JavaScript/CMakeLists.txt | CMake target for the native static library (conditional on GEN_PINVOKE). |
| src/native/libs/System.JavaScript/libSystem.JavaScript.js | Dummy PAL library functions (e.g., random bytes) and Emscripten integration. |
| src/native/libs/System.JavaScript/libSystem.JavaScript.extpost.js | Post-JS module to expose initialize entrypoint and create the Emscripten runtime. |
| src/native/libs/System.JavaScript/entrypoints.c | C entrypoints mapping to JS PAL functions for P/Invoke resolution. |
| src/native/libs/System.JavaScript/ReadMe.md | Documentation stub for the System.JavaScript PAL library. |
| src/native/libs/System.JavaScript/CMakeLists.txt | CMake target for System.JavaScript static lib and temporary JS asset installation. |
| src/native/libs/System.JavaScript.Runtime/dotnet.runtime.js | Minimal placeholder runtime JS module to satisfy build. |
| src/native/libs/System.JavaScript.Runtime/ReadMe.md | Documentation stub for the runtime module. |
| src/native/libs/System.JavaScript.Loader/dotnet.js | Loader/host ES module orchestrating runtime/wasm and assembly loading for browser/NodeJS. |
| src/native/libs/System.JavaScript.Loader/ReadMe.md | Documentation stub for the loader module. |
| src/native/libs/Common/JavaScript/types/index.ts | Barrel for shared type definitions. |
| src/native/libs/Common/JavaScript/types/emscripten.ts | Type definitions for Emscripten Module and pointers. |
| src/native/libs/Common/JavaScript/common/index.ts | Placeholder for shared helpers. |
| src/native/libs/Common/JavaScript/ReadMe.md | Documentation for shared types/helpers. |
| src/native/libs/CMakeLists.txt | Includes new JS libs for browser target builds. |
| src/native/libs/.eslintrc.cjs | ESLint configuration for TS/JS. |
| src/native/libs/.eslintignore | Ignore generated and JS files for linting. |
| src/native/corehost/browser/native.rc | Windows resource file for host. |
| src/native/corehost/browser/main.mjs | Simple NodeJS/browser host entrypoint (demo). |
| src/native/corehost/browser/libBrowserHost.js | Emscripten library exposing browser host callbacks and initializing DOTNET/interop. |
| src/native/corehost/browser/index.html | Minimal HTML for browser demo. |
| src/native/corehost/browser/dotnet.boot.js | Demo asset manifest for browser boot. |
| src/native/corehost/browser/configure.cmake | Configure checks and generated config header. |
| src/native/corehost/browser/config.h.in | Generated config header template. |
| src/native/corehost/browser/browserhost.cpp | CoreCLR bootstrapper using host runtime contract for JS/browser scenario. |
| src/native/corehost/browser/CMakeLists.txt | CMake target for browserhost, linking JS libraries and setting emscripten flags. |
| src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props | Adds new native libs to platform manifest. |
| src/coreclr/vm/wasm/helpers.cpp | Removes temporary stub now provided by JS PAL. |
| src/coreclr/vm/CMakeLists.txt | Adds include paths for new JS libs on browser builds. |
| src/coreclr/hosts/corewasmrun/CMakeLists.txt | Links System.JavaScript lib into corewasmrun. |
| src/coreclr/hosts/corerun/libCorerun.pre.js | Pre-run script to copy Node env vars into Emscripten ENV. |
| src/coreclr/hosts/corerun/corerun.js | Removes old pre-js; replaced by libCorerun.pre.js. |
| src/coreclr/hosts/corerun/CMakeLists.txt | Wires new pre-js and System.JavaScript lib when targeting browser. |
| src/coreclr/CMakeLists.txt | Adds browserhost build and dependency for browser target. |
| eng/pipelines/common/evaluate-default-paths.yml | Ensures CI path filters include new JS/browser-host folders. |
| docs/workflow/building/coreclr/wasm.md | Adds VS Code NodeJS launch config for browserhost demo. |
...bs/System.Runtime.InteropServices.JavaScript/libSystem.Runtime.InteropServices.JavaScript.js
Outdated
Show resolved
Hide resolved
src/native/libs/System.Runtime.InteropServices.JavaScript/ReadMe.md
Outdated
Show resolved
Hide resolved
|
This is ready for initial feedback. I'm also working on much nicer TypeScript version, but it needs more of my work. |
|
The parts I understand look pretty good. |

Skeleton for JavaScript host
The goal on this PR is to establish directory structure and naming.
All new
*.jsfiles areartifacts\objartifacts\obj\native\<RID>\System.Native.Browser\next tolibSystem.Native.Browser.aFunctionality
As compared to current WASM corerun, this could run in a browser as well as in NodeJS.
In NodeJS it expects all managed assemblies in the current folder and name of main assembly as first argument.
In browser, it loads assets as defined in
dotnet.boot.js, which you can edit before you host it withdotnet-serveThe assemblies are loaded asynchronously and put into memory via
external_assembly_probecallback.All of this would be further integrated with existing Mono WASM SDK later.
New files
src\native\corehost\browserhost\libBrowserHost.js- implementsexternal_assembly_probecallbackbrowserhost.cpp- creates coreCLR instanceTRUSTED_PLATFORM_ASSEMBLIESas env var for the PoC, to be improved.samplefilesindex.html- target web pagemain.mjs- this is demo of the NodeJS usage.dotnet.boot.js- list of assets to download. This going to be generated by MSBuild of the WASM SDK later. It's 100% compatible with Mono/Blazorloaderdotnet.jsfile in the final product.src\native\libs\Common\JavaScriptsrc\native\libs\System.Native.Browser\libSystem.Native.Browser.js- JS part of the librarylibSystem.Native.Browser.extpost.js- ES6 exports helpersCMakeLists.txt,entrypoints.c- native part of the library. C exports for P/Invoke.src\native\libs\System.Runtime.InteropServices.JavaScript.Native\libSystem.Runtime.InteropServices.JavaScript.Native.js- JS part of the libraryCMakeLists.txt,entrypoints.c- native part of the library. C exports for P/Invoke.dotnet.runtime.jsdotnet.runtime.jsfile in the final product.src\native\package.json,package-lock.json,.npmrc- npm package definition and dependencies.eslintrc.cjs,.eslintrc.cjs- JS code stylerollup.config.js- JS bundler and build script for TypeScripttsconfig.json- typescript configurationQ & A
src\mono\browser\runtime, are we going to reuse them ?Main()needs to yield to browser event loop and marshalTask/Promise. Synchronousmainis not very useful in JS.Fixes #119685
Contributes to #113067