Skip to content

stagehand-python@4.5.0a0.dev1709

@miguelg719 miguelg719 tagged this 17 Nov 00:45
# why

- the extension ships unminified inside the sdk packages, and its zip is
uploaded on every browserbase session create that has no `extensionId`

# what changed

- build the extension with vite's oxc minifier, keeping function and
class names so stack traces and logs stay readable
- extension zip: 562 kB → 366 kB; service worker: 2,522 kB → 1,434 kB;
content script: 36 kB → 19 kB
- wrap the content script in its own function scope: it runs as a
classic script, so its top-level bindings were page globals on the
extension's blank page. minified one-letter names would collide with
user init scripts and `page.evaluate` code, and today a user init script
declaring `let scope` already breaks `newPage()`
- fail the build if a node built-in ends up in a bundle; this replaces
text checks that cannot see it in minified output
- tests: bundle is minified and keeps class and function names; content
script adds no page globals (build test + a real-chrome test)

# test plan

- extension unit tests (1192) and sdk-ts unit tests (620) pass
- sdk-ts browser-runtime suite passes against real chrome (48 tests); 16
of those build or load their own extension, so the minified bundle is
covered by the other 32 and by the integration jobs in ci
- the two new scope tests fail without the wrapper and pass with it
- two consecutive builds produce a byte-identical zip
Assets 2
Loading