Add http client js to the playground#10165
Merged
timotheeguerin merged 6 commits intoApr 30, 2026
Merged
Conversation
commit: |
Contributor
|
All changed packages have been documented.
|
Collaborator
|
You can try these changes here
|
…ture/http-client-js-playground
markcowl
approved these changes
Apr 29, 2026
markcowl
approved these changes
Apr 30, 2026
github-merge-queue Bot
pushed a commit
that referenced
this pull request
May 1, 2026
…nd upload (#10582) Fixes the `Upload playground bundle` Azure DevOps pipeline step that was failing with: ``` packages/http-client-csharp/dist/emitter/src/emitter.js:5:24: ERROR: Could not resolve "path" packages/http-client-csharp/dist/emitter/src/lib/utils.js:4:22: ERROR: Could not resolve "child_process" ``` ## Root cause PR #10165 ("Add http client js to the playground", merged Apr 30) removed `nodeModulesPolyfillPlugin` from `packages/bundler/src/bundler.ts`. Until then, the bundler silently polyfilled Node built-ins like `path`, `fs`, and `url` (and stubbed `child_process`), which masked the fact that: - `emitter.ts` imports `resolve` from Node `path`. - `lib/utils.ts` imports `spawn` from `child_process` for `execCSharpGenerator` / `execAsync`, and `lib/utils.ts` is reached transitively from `emitter.ts` via shared helpers like `getClientNamespaceString` / `isReadOnly`. The `"browser"` field in `package.json` only swaps `emit-generate.js` for `emit-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 1. Move `execCSharpGenerator`, `execAsync`, and `processJsonRpc` (the only `child_process` users) out of `lib/utils.ts` into a new `lib/exec-utils.ts`. `lib/exec-utils.ts` is only imported from `emit-generate.ts` (the Node-only generation entry point), so the browser bundle (which loads `emit-generate.browser.ts` via the `browser` field) never reaches it. 2. Replace `import { resolve } from "path"` in `emitter.ts` with `resolvePath` from `@typespec/compiler` (the cross-platform TypeSpec utility used elsewhere in the emitter). 3. Update tests to import from the new location. This is the right fix even with the polyfill plugin in place — `child_process` was 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) - Local `esbuild` bundle of `dist/emitter/src/emitter.js` for `platform: 'browser'` succeeds with no unresolved Node modules. --generated by Copilot Co-authored-by: Joshua Love <joshualove@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Changes: