Skip to content

Prebidexternal first-party bundle loading#743

Open
ChristianPavilonis wants to merge 4 commits into
mainfrom
feature/prebid-bundle-update
Open

Prebidexternal first-party bundle loading#743
ChristianPavilonis wants to merge 4 commits into
mainfrom
feature/prebid-bundle-update

Conversation

@ChristianPavilonis

@ChristianPavilonis ChristianPavilonis commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Hard cut Prebid to the external first-party bundle flow: no bundle_mode, no embedded/deferred tsjs-prebid loading, and external_bundle_url is required whenever Prebid is enabled.
  • Always inject the same-origin /integrations/prebid/bundle.js script and keep publisher Prebid script interception/removal to prevent duplicate instances.
  • Proxy the generated bundle with static-asset behavior: no EC forwarding, no copied request headers, streaming passthrough, HTTPS-only targets/redirects, and proxy.allowed_domains enforcement.
  • Keep external_bundle_sha256 optional; when present it drives versioned first-party URLs, immutable cache headers, and sha256: ETags. SRI is validated if configured but is not required.
  • Move Prebid out of the embedded Cargo TSJS build and document/generate publisher-specific external bundles with build-prebid-external.mjs.

Quick how-to: generate and configure a Prebid bundle

  1. Generate a publisher-specific external Prebid bundle:
cd crates/js/lib
npm run build:prebid-external -- \
  --adapters=rubicon,appnexus,openx \
  --user-id-modules=sharedIdSystem,uid2IdSystem \
  --out=dist/prebid
  1. Upload the generated trusted-prebid-<sha256>.js from dist/prebid/ to an HTTPS asset host that is allowed by proxy.allowed_domains.

  2. Copy values from dist/prebid/manifest.json into config:

[integrations.prebid]
enabled = true
server_url = "https://prebid-server.example.com/openrtb2/auction"
external_bundle_url = "https://assets.example.com/prebid/trusted-prebid-<sha256>.js"

# Optional but recommended for versioned first-party URL + immutable cache headers.
external_bundle_sha256 = "<manifest sha256>"

# Optional browser SRI. Validated if present, but not required.
external_bundle_sri = "<manifest sri>"

# Include any client-side bidders whose adapters were included above.
client_side_bidders = ["rubicon"]

Trusted Server injects the same-origin /integrations/prebid/bundle.js route for browsers; publishers should not reference the external asset URL directly in page markup.

Testing

  • cargo fmt --all -- --check
  • TSJS_SKIP_BUILD=1 cargo check -p trusted-server-core
  • TSJS_SKIP_BUILD=1 cargo test -p trusted-server-core prebid --lib
  • TSJS_SKIP_BUILD=1 cargo test -p trusted-server-core publisher::tests --lib
  • TSJS_SKIP_BUILD=1 cargo test -p trusted-server-core registry::tests --lib
  • TSJS_SKIP_BUILD=1 cargo test --workspace
  • TSJS_SKIP_BUILD=1 cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo check -p trusted-server-js
  • cd crates/js/lib && npm run build
  • cd crates/js/lib && npm run format
  • cd crates/js/lib && npx vitest run
  • cd crates/js/lib && npm run build:prebid-external -- --adapters=rubicon --user-id-modules=sharedIdSystem --out=/tmp/trusted-server-prebid-external-hard-cutover
  • cd docs && npm ci && npm run format

@ChristianPavilonis ChristianPavilonis linked an issue Jun 4, 2026 that may be closed by this pull request
@aram356 aram356 requested a review from jevansnyc June 4, 2026 15:53
@ChristianPavilonis ChristianPavilonis changed the title Add external Prebid bundle proxy spec Add managed external Prebid bundle loading Jun 9, 2026
@ChristianPavilonis ChristianPavilonis changed the title Add managed external Prebid bundle loading Hard cut Prebid to external first-party bundle loading Jun 9, 2026

Client-side bidders need their Prebid.js adapter modules bundled in the JS output. This is controlled by the `TSJS_PREBID_ADAPTERS` environment variable at build time:
Client-side bidders need their Prebid.js adapter modules included in the generated external bundle:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bundling should be moved to CLI when ready.

@ChristianPavilonis ChristianPavilonis changed the title Hard cut Prebid to external first-party bundle loading Prebidexternal first-party bundle loading Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better TSJS prebid bundle onboarding

1 participant