[browser][coreCLR] rollup improvements#122814
Merged
pavelsavara merged 11 commits intodotnet:mainfrom Jan 6, 2026
Merged
Conversation
Contributor
|
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the TypeScript module organization for the browser/CoreCLR JavaScript interop layer by introducing an _ems_ helper that gets elided during rollup compilation. The primary goal is to eliminate confusing global declarations that were visible across all TypeScript files, replacing them with a proper module-based approach through the new ems-ambient module.
Key changes:
- Introduces
_ems_prefix to access Emscripten ambient symbols, which gets stripped by a new rollup plugin during compilation - Replaces global
declare globalstatements with a typed module pattern inems-ambient/index.ts - Removes circular dependency between
host-builder.tsandassets.tsby introducingsetLoadBootResourceCallback
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/tsconfig.json | Updates comment reference from rollup.config.defines.js to rollup.config.js |
| src/native/rollup.config.plugins.js | Adds new emsAmbient plugin to strip _ems_. prefix; removes onwarn filters for circular dependencies and other warnings |
| src/native/rollup.config.js | Imports and configures new emsAmbient plugin; adds external dependencies parameter support |
| src/native/rollup.config.defines.js | Updates banner comment, reorders reserved names to include _ems_, changes isDebug to be false on CI builds |
| src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts | Replaces cross-linked import with ems-ambient; uses _ems_. prefix for ambient symbols |
| src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/cross-linked.ts | Removes file (deleted) |
| src/native/libs/System.Native.Browser/utils/index.ts | Renames export from cross to _ems_ambient_ |
| src/native/libs/System.Native.Browser/utils/host.ts | Converts all ambient symbol usages to _ems_. prefix pattern |
| src/native/libs/System.Native.Browser/utils/cross-module.ts | Removes trailing newline |
| src/native/libs/System.Native.Browser/utils/cross-linked.ts | Removes file (deleted) |
| src/native/libs/System.Native.Browser/utils/cdac.ts | Updates to use _ems_. prefix for Module and function access |
| src/native/libs/System.Native.Browser/native/timer.ts | Converts timer functions to use _ems_. prefix; removes __deps annotations |
| src/native/libs/System.Native.Browser/native/main.ts | Updates promise resolution functions to use _ems_. prefix |
| src/native/libs/System.Native.Browser/native/index.ts | Adds ems-ambient import; updates dotnetUpdateInternals call |
| src/native/libs/System.Native.Browser/native/globalization-locale.ts | Uses _ems_. prefix throughout; replaces VoidPtrNull with 0 as any |
| src/native/libs/System.Native.Browser/native/crypto.ts | Updates to use _ems_. prefix for all ambient symbols |
| src/native/libs/System.Native.Browser/native/cross-linked.ts | Removes file (deleted) |
| src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js | Updates commonDeps to reference timer callbacks directly; removes __deps handling loop |
| src/native/libs/System.Native.Browser/libSystem.Native.Browser.Utils.footer.js | Updates to iterate over _ems_ambient_ instead of cross; adds explanatory comment |
| src/native/libs/Common/JavaScript/per-module/index.ts | Adds VoidPtrNull, CharPtrNull, and NativePointerNull constants (moved from cross-module) |
| src/native/libs/Common/JavaScript/ems-ambient/index.ts | New file defining emAmbientSymbolsType and exporting _ems_ object |
| src/native/libs/Common/JavaScript/cross-module/index.ts | Exports dotnetInternals; removes VoidPtrNull, CharPtrNull, NativePointerNull constants |
| src/native/libs/Common/JavaScript/cross-linked/index.ts | Removes file (deleted) |
| src/native/libs/Common/JavaScript/CMakeLists.txt | Updates ROLLUP_TS_SOURCES to replace cross-linked.ts references with ems-ambient/index.ts |
| src/native/corehost/browserhost/loader/host-builder.ts | Imports setLoadBootResourceCallback from assets; removes loadBootResourceCallback export |
| src/native/corehost/browserhost/loader/dotnet.d.ts | Updates comment reference to rollup.config.js |
| src/native/corehost/browserhost/loader/assets.ts | Adds setLoadBootResourceCallback function to break circular dependency; moves loadBootResourceCallback to local variable |
| src/native/corehost/browserhost/libBrowserHost.footer.js | Removes __deps handling loop |
| src/native/corehost/browserhost/host/index.ts | Replaces cross-linked import with ems-ambient; uses _ems_. prefix |
| src/native/corehost/browserhost/host/host.ts | Converts all Module and function calls to use _ems_. prefix |
| src/native/corehost/browserhost/host/cross-linked.ts | Removes file (deleted) |
This was referenced Jan 5, 2026
Open
This was referenced Jan 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
motivation: the global declarations are visible in all .ts files, even those which are not inside of emscripten
dotnet.native.jsmodule and do not share it's closure. Which leads to confusing typescript behavior._ems_helper that is elided during rollup compilationems-ambient/index.tsto become fake module, rather than global declarationemsAmbientplugin in rollup to do thiscrossexport to_ems_ambient_for better discoverability.VoidPtrNull,CharPtrNull,NativePointerNullonwarnfiltersloadBootResourceCallback