Decouple the prebid tsjs shim from the bundled Prebid.js#967
Open
aram356 wants to merge 1 commit into
Open
Conversation
The external bundle is now pure Prebid.js (core, consent and user ID modules, client-side bid adapters) and stamps a manifest on window.__tsjs_prebid_bundle. The shim ships as a server-served deferred tsjs module that installs the trustedServer adapter onto the window.pbjs global via public APIs only, so shim fixes deploy with the server instead of requiring an external bundle re-upload.
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
The prebid tsjs shim (the
trustedServeradapter,requestBidswrapper, and Prebid config glue) was compiled into the external Prebid bundle:build-prebid-external.mjsused the shim as its entry point and importedprebid.jsplus internal modules directly. Any shim change therefore required rebuilding and re-uploading the external bundle and repointingexternal_bundle_sha256/external_bundle_sri— server deploys alone could never change client behavior.This PR separates the two artifacts:
userId, and the selected--adapters/--user-id-modules— no shim code. It stamps a manifest onwindow.__tsjs_prebid_bundle({adapters, userIdModules}) and intentionally does not callprocessQueue(); the shim keeps driving queue processing after it installs the adapter, preserving the existing ordering semantics.build-all.mjsno longer excludes prebid, and the Rust registration switches.without_js()→.with_deferred_js(), so the shim ships astsjs-prebidvia the/static/tsjs=route. It uses thewindow.pbjsglobal (the head-injected stub object that Prebid.js mutates in place) with a type-onlyimport typefor typing, and fails loudly if the external bundle did not load (noregisterBidAdapteron the global).adapterManager.getBidAdapter(an internal import) is replaced by validatingclient_side_biddersagainst the stamped manifest; the previously bundled consent/userId module imports move into the external bundle entry.Why
Shim fixes should reach production with a normal server deploy. With this split, the external bundle only changes when the Prebid.js version or the adapter/user-ID selection changes.
Verification
cargo fmt --all -- --check-D warningscargo testfor core + fastly (1658 + 109), axum, cloudflare, spin, and the parity integration suite (13)npx vitest run(412 tests) andnpm run formattsjs-prebid.jsshim (~23 KB, no Prebid core markers) and the pure external bundle (reproducible content hash across builds)window.pbjs(v10.26.0) and stamps the manifest, the deferred shim registers thetrustedServeradapter and wrapsrequestBids, server-side/auctionand client-side bidders both return bids, andhb_*targeting reaches every GPT slot with zero Prebid console errorsDeployment note
The currently deployed external bundle contains the old baked-in shim, so this change and a regenerated pure bundle should roll out together: upload the new bundle, update
external_bundle_sha256/external_bundle_sri, and deploy the server. Running the new server against the old bundle would install the adapter twice.Old-architecture guard tests (asserting the shim must not be served as embedded tsjs) are inverted to assert the new behavior.