fix(http-client-csharp): make emitter browser-bundleable for playground upload#10582
Merged
JoshLove-msft merged 1 commit intoMay 1, 2026
Merged
Conversation
…dleable
Moves the Node-only execCSharpGenerator/execAsync helpers (which use
child_process) out of lib/utils.ts and into a new lib/exec-utils.ts that
is only imported from emit-generate.ts (the Node-only generation entry
point). The browser variant (emit-generate.browser.ts) does not import
exec-utils, so child_process is no longer pulled into the browser bundle.
Also replaces `import { resolve } from "path"` in emitter.ts with the
cross-platform `resolvePath` utility from @typespec/compiler so that
emitter.ts no longer has a direct dependency on the Node `path` module.
This fixes the "Upload playground bundle" pipeline step that was failing
with:
emitter.js: Could not resolve "path"
lib/utils.js: Could not resolve "child_process"
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
commit: |
Contributor
|
No changes needing a change description found. |
jorgerangel-msft
approved these changes
May 1, 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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes the
Upload playground bundleAzure DevOps pipeline step that was failing with:Root cause
PR #10165 ("Add http client js to the playground", merged Apr 30) removed
nodeModulesPolyfillPluginfrompackages/bundler/src/bundler.ts. Until then, the bundler silently polyfilled Node built-ins likepath,fs, andurl(and stubbedchild_process), which masked the fact that:emitter.tsimportsresolvefrom Nodepath.lib/utils.tsimportsspawnfromchild_processforexecCSharpGenerator/execAsync, andlib/utils.tsis reached transitively fromemitter.tsvia shared helpers likegetClientNamespaceString/isReadOnly.The
"browser"field inpackage.jsononly swapsemit-generate.jsforemit-generate.browser.js— it doesn't help with these other files. With the polyfill plugin gone, the next C# publish run hit unresolved-module errors on those long-standing imports.Fix
execCSharpGenerator,execAsync, andprocessJsonRpc(the onlychild_processusers) out oflib/utils.tsinto a newlib/exec-utils.ts.lib/exec-utils.tsis only imported fromemit-generate.ts(the Node-only generation entry point), so the browser bundle (which loadsemit-generate.browser.tsvia thebrowserfield) never reaches it.import { resolve } from "path"inemitter.tswithresolvePathfrom@typespec/compiler(the cross-platform TypeSpec utility used elsewhere in the emitter).This is the right fix even with the polyfill plugin in place —
child_processwas never going to work at runtime in the browser, so relying on the bundler to silently include it was a latent footgun.Verified
npm run build:emitter✅npm run test:emitter✅ 205 passed (2 skipped)esbuildbundle ofdist/emitter/src/emitter.jsforplatform: 'browser'succeeds with no unresolved Node modules.--generated by Copilot