Repository navigation
[python] Refactor Python emitter node imports to be browser bundleable - #10844
Merged
jenny (JennyPng) merged 6 commits intoJun 12, 2026
Merged
Conversation
commit: |
Contributor
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Python HTTP client emitter to be browser-bundleable by isolating Node-only functionality behind swap-in modules selected via the package "browser" field, and by avoiding static imports that pull in Node built-ins when bundling for the browser (notably via pyodide).
Changes:
- Adds package-level
"browser"mappings to swap Node implementations for browser stubs at bundle time. - Extracts Node-only emit execution into
node-runner.tsand adds a browser stub implementation. - Introduces a
pyodide-loaderabstraction, with a browser implementation that loads Pyodide via CDN script injection.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/http-client-python/package.json | Adds "browser" field mappings to swap Node runner and Pyodide loader for browser builds. |
| packages/http-client-python/emitter/src/emitter.ts | Removes direct Node built-in imports and delegates Node path to runNodeEmit; uses pyodide-loader abstraction. |
| packages/http-client-python/emitter/src/node-runner.ts | New Node-only module containing filesystem/process execution and native Python/Pyodide NodeFS paths. |
| packages/http-client-python/emitter/src/node-runner.browser.ts | New browser stub that emits a diagnostic if Node path is reached in a browser bundle. |
| packages/http-client-python/emitter/src/pyodide-loader.ts | Node-side re-export wrapper around the pyodide package APIs. |
| packages/http-client-python/emitter/src/pyodide-loader.browser.ts | Browser loader that injects pyodide.js via <script> instead of importing pyodide into the bundle. |
| .chronus/changes/refactor-node-python-emitter-2026-5-3-15-23-59.md | Adds a Chronus entry documenting the internal refactor. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
jenny (JennyPng)
marked this pull request as ready for review
June 12, 2026 17:28
iscai-msft
approved these changes
Jun 12, 2026
Timothee Guerin (timotheeguerin)
approved these changes
Jun 12, 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.
local validation:
typespec-azurerepo, overrode and installed this branch's http-client-python and checked that/typespec-azure-playground-websiteis able to start when includingtypespec-python