Title: wasm build: publish the bundler glue and/or an eval-free build (extensions and other no-eval environments) · Issue #9990 · RustPython/RustPython · GitHub
Open Graph Title: wasm build: publish the bundler glue and/or an eval-free build (extensions and other no-eval environments) · Issue #9990 · RustPython/RustPython
X Title: wasm build: publish the bundler glue and/or an eval-free build (extensions and other no-eval environments) · Issue #9990 · RustPython/RustPython
Description: Context We embed RustPython (rustpython_wasm@0.1.0-pre-alpha.2) in Chrome extensions, where the application layer is Python. Two packaging facts make that hard, and both look fixable upstream: 1. No glue module in the package. The ESM en...
Open Graph Description: Context We embed RustPython (rustpython_wasm@0.1.0-pre-alpha.2) in Chrome extensions, where the application layer is Python. Two packaging facts make that hard, and both look fixable upstream: 1. N...
X Description: Context We embed RustPython (rustpython_wasm@0.1.0-pre-alpha.2) in Chrome extensions, where the application layer is Python. Two packaging facts make that hard, and both look fixable upstream: 1. N...
Opengraph URL: https://github.com/RustPython/RustPython/issues/9990
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"wasm build: publish the bundler glue and/or an eval-free build (extensions and other no-eval environments)","articleBody":"## Context\n\nWe embed RustPython (`rustpython_wasm@0.1.0-pre-alpha.2`) in Chrome extensions, where\nthe application layer is Python. Two packaging facts make that hard, and both look\nfixable upstream:\n\n**1. No glue module in the package.** The ESM entry does\n`import * as wasm from \"./rustpython_wasm_bg\"`, but the package ships only\n`rustpython_wasm.js`, `.d.ts` and `_bg.wasm`. That expects WebAssembly ESM\nintegration (importing a `.wasm` as a module), which browsers still gate behind a\nflag. We worked around it by patching the ESM to accept an instance — the wasm's\n80 imports come from that same module (`./rustpython_wasm`), so it closes — but that\nis us maintaining a fork of generated code, which nobody should have to do. Shipping\nthe `_bg.js` from a `--target bundler`/`--target web` build would fix it.\n\n**2. The glue requires `eval`.** The generated code compiles strings with `eval`\n(Emscripten \"asm consts\"). Chrome extension pages cannot enable `unsafe-eval` — the\npolicy is fixed by the platform — so the only way to run RustPython is to host it in\na manifest **sandbox** page. That works (we ship it), but it costs us an opaque\norigin: no `chrome.*` APIs, no access to the page, every DOM op proxied through\n`postMessage`. For a 5 MB interpreter that is a lot of tax.\n\n## Ask\n\nEither of these would remove the sandbox requirement:\n\n- **a build without eval**: wasm-bindgen/Emscripten can often avoid `Function`/`eval`\n (static imports for the known `asm consts`, or `-sDYNAMIC_EXECUTION=0` style\n settings). Even a partial reduction that covers the paths a plain `pyEval` uses\n would let us run in a normal extension page.\n- **a documented bundling recipe** for browsers without wasm ESM integration, so\n consumers are not hand-patching generated glue.\n\n## Why it matters beyond us\n\nExtensions, desktop shells and other environments that treat \"no eval\" as a hard\nrequirement (CSP, app-store review, embedded webviews) currently cannot use\nRustPython at all without a sandbox hop. A build flag is the difference between\n\"usable\" and \"not usable\" for that whole class of consumer.\n\nHappy to test a build and report results — our harness runs real Chromium and\nasserts the interpreter boots and reaches the DOM, so we can verify quickly.\n","author":{"url":"https://github.com/ShyftXero","@type":"Person","name":"ShyftXero"},"datePublished":"2026-11-22T07:20:56Z","url":"https://github.com/RustPython/RustPython/issues/9990"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3a73d28a-4651-45fd-1957-97cd3bcae223 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C454:1293AE:928581:BE3EA1:6B06324A |
| html-safe-nonce | a5a08c683094e4d6508995857f292e925d3210ac201bc9e1a0ce43659bbab5e3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDU0OjEyOTNBRTo5Mjg1ODE6QkUzRUExOjZCMDYzMjRBIiwidmlzaXRvcl9pZCI6IjczMTg4OTU4MjM0ODY4NTc4MDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d1286e1882033c02a7f5044d6a6ffa3e1e97e7d7801da5c973a543cef22e8540 |
| hovercard-subject-tag | issue:6539757258 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RustPython/RustPython/9990/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c2fddb202fbd9367eb90d8d3ea7b89cd4a6946a705294298daa3e30187b91224/RustPython/RustPython/issues/9990 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c2fddb202fbd9367eb90d8d3ea7b89cd4a6946a705294298daa3e30187b91224/RustPython/RustPython/issues/9990 |
| og:image:alt | Context We embed RustPython (rustpython_wasm@0.1.0-pre-alpha.2) in Chrome extensions, where the application layer is Python. Two packaging facts make that hard, and both look fixable upstream: 1. N... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ShyftXero |
| hostname | github.com |
| expected-hostname | github.com |
| None | c3584c853cd39700ecff6e2cf8364295ffdb5313e571046c41cd2479270f7df0 |
| turbo-cache-control | no-preview |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9eb3bb1597d09170a5f282cd38ae376dee1a5ec1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width