Repository navigation
Fix Python playground bundle esbuild failure by isolating browser-safe YAML util - #11811
Merged
Merged
Conversation
…e YAML util emitter.ts imports dumpCodeModelToYaml from external-process.ts for use on the browser/Pyodide path, but external-process.ts also contains Node-only code (execAsync, saveCodeModelAsYaml) using child_process/crypto/fs/os. Since emitter.ts isn't swapped for a browser stub (only node-runner.js is), esbuild bundled the whole file with platform: browser, failing to resolve those Node builtins during the playground bundle upload step. Move dumpCodeModelToYaml into a new browser-safe yaml-utils.ts module and have both emitter.ts and external-process.ts import it from there. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ate-python-publish
iscai-msft
requested review from
Chenxi Jiang (ChenxiJiang333),
catalinaperalta,
Kashif Khan (kashifkhan),
Libba Lawrence (l0lawrence),
Laurent Mazuel (lmazuel),
Mark Cowlishaw (markcowl),
Yuchao Yan (msyyc),
Chenjie Shi (tadelesh),
Timothee Guerin (timotheeguerin) and
Jeff Fisher (xirzec)
as code owners
September 1, 2026 18:13
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
commit: |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a browser-playground bundling failure for @typespec/http-client-python by preventing Node-only dependencies from being pulled into the browser (Pyodide) bundle.
Changes:
- Extracted
dumpCodeModelToYamlinto a new browser-safe module (yaml-utils.ts) so it can be used from the browser code path without importing Node built-ins. - Updated
emitter.ts(browser/Pyodide path) andexternal-process.ts(Node-only path) to importdumpCodeModelToYamlfrom the new module. - Updated the existing YAML-quoting test to reference the new module and renamed the suite to match.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/http-client-python/emitter/test/yaml-utils.test.ts | Updates test imports and suite name to validate YAML quoting via the new browser-safe helper module. |
| packages/http-client-python/emitter/src/yaml-utils.ts | Introduces a dedicated browser-safe YAML serialization helper used by both browser and Node paths. |
| packages/http-client-python/emitter/src/external-process.ts | Removes inline YAML dump logic and reuses the extracted helper while keeping Node-only process/file code here. |
| packages/http-client-python/emitter/src/emitter.ts | Switches the browser/Pyodide path to use the new YAML helper without importing Node-only modules. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
Timothee Guerin (timotheeguerin)
approved these changes
Sep 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.
Summary
PR #11800 fixed the pip/PyPI authentication failure in the Python playground publish job, but a subsequent publish build (6772679) failed later in the same job, at the "Upload playground bundle" step:
Root cause
emitter.tsimportsdumpCodeModelToYamlfromexternal-process.tsfor use on the browser/Pyodide code path. However,external-process.tsalso contains Node-only code (execAsync,saveCodeModelAsYaml) that useschild_process,crypto,fs/promises, andos.Only
node-runner.jsis swapped out for a browser-safe stub via the"browser"field inpackage.json;emitter.tsis not. As a result, when esbuild bundles the emitter for the browser playground (platform: "browser"), it pulls in all ofexternal-process.ts, including the Node-only imports, which can't be resolved for a browser target.Fix
Extracted
dumpCodeModelToYaml(a pure, browser-safe YAML serialization helper) into a newyaml-utils.tsmodule. Bothemitter.ts(browser path) andexternal-process.ts(Node-only path, still used bynode-runner.ts) now import it from there, so no Node builtins leak into the browser bundle.Validation
npx tsc -p ./emitter/tsconfig.build.json— passes with no errorsnpx tsx ./eng/scripts/ci/run-tests.ts --emitter— 21/21 tests passcreateTypeSpecBundlefrom@typespec/bundler) and confirmed it is resolved after this change.