Skip to content

Fix browser-targeting builds: move declare global from public-api.ts to export-api.ts#125014

Merged
jkotas merged 3 commits intomainfrom
copilot/fix-browser-targeting-builds
Mar 1, 2026
Merged

Fix browser-targeting builds: move declare global from public-api.ts to export-api.ts#125014
jkotas merged 3 commits intomainfrom
copilot/fix-browser-targeting-builds

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Description

Browser WASM builds fail with rollup-plugin-dts v6.2.3 + rollup 4.59.0:

[!] RollupError: Exported variable "global" is not defined in "libs/Common/JavaScript/types/public-api.ts".

rollup-plugin-dts classifies a file as a "global module" if it has imports but no standalone export {} / export default statement — causing all declared names to be treated as exports. public-api.ts uses only inline exports (export interface, export type, etc.), so isGlobalModule() returns true for it. This causes the declare global {} block's name "global" to be added to rollup's export list. Rollup 4.59.0 then strictly validates that every exported name resolves to a real variable, and global (a TypeScript ambient augmentation, not a variable) fails that check.

Fix: Move declare global {} from public-api.ts to export-api.ts (the rollup entry point), which already has a standalone export { ... } statement that makes isGlobalModule() return false. This matches the existing pattern in the Mono/browser runtime's export-types.ts.

  • public-api.ts — remove declare global {}
  • export-api.ts — add declare global {} (entry point; correctly treated as scoped module)
  • dotnet.d.ts (generated) — regenerated; semantically identical, minor declaration reordering

Customer Impact

Browser/WASM targeting builds fail entirely — no output produced.

Regression

Yes, introduced by the rollup 4.59.0 package update which added strict validation that exported variable names resolve to real variables.

Testing

Reproduced the failure locally with the exact CI rollup invocation (Configuration:RELEASE), confirmed it is resolved after the fix. TypeScript type check (tsc --noEmit) passes. Generated dotnet.d.ts output is semantically identical to pre-fix.

Risk

Low. The change only affects where the declare global {} augmentation lives in the TypeScript source. The generated .d.ts API surface is unchanged.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • helixr1107v0xdcypoyl9e7f.blob.core.windows.net
    • Triggering command: /usr/bin/pwsh pwsh .github/skills/ci-analysis/scripts/Get-CIStatus.ps1 -BuildId 1314502 -ShowLogs (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Feb 28, 2026
…o export-api.ts

Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix browser targeting builds failing with Rollup error Fix browser-targeting builds: move declare global from public-api.ts to export-api.ts Feb 28, 2026
@github-actions github-actions bot added area-System.Globalization and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Feb 28, 2026
@jkotas jkotas marked this pull request as ready for review February 28, 2026 21:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Browser/WASM build failure in the JavaScript type bundling pipeline by relocating a TypeScript declare global {} augmentation from a file that rollup-plugin-dts misclassifies as a “global module” to the rollup entrypoint module.

Changes:

  • Removed declare global { ... } from public-api.ts to avoid rollup exporting an ambient name.
  • Added the same declare global { ... } block to export-api.ts, which is already an explicit module/entrypoint for the d.ts bundle.
  • Regenerated dotnet.d.ts with only ordering changes (API surface unchanged).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
src/native/libs/Common/JavaScript/types/public-api.ts Removes the ambient global augmentation that rollup-plugin-dts was incorrectly treating as an export.
src/native/libs/Common/JavaScript/types/export-api.ts Adds the declare global augmentation to the rollup entrypoint module so bundling succeeds.
src/native/libs/Common/JavaScript/loader/dotnet.d.ts Regenerated output reflecting the move (minor declaration reordering).

@jkotas
Copy link
Member

jkotas commented Feb 28, 2026

@akoeplinger @pavelsavara The browser builds are on the floor across the board after the rollup npm package update from #124987 . The new version is more nit-picky. I am not sure why this was not caught by the CI in #124987 .

@pavelsavara
Copy link
Member

src\mono\browser\runtime\package.json will need same upgrade and probably same global fix for Mono

@akoeplinger
Copy link
Member

@pavelsavara the rollup upgrade in src/mono went in with #124910

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants