Skip to content

TSJS core imports the APS renderer directly, so a second bid-renderer vendor cannot be added without changing core #1111

Description

@jwrosewell

Reported for the core team. This is pre-existing on main and is not
introduced or changed by any currently open pull request. Raising it for the
record rather than because it blocks us.

What

The browser bundle's core imports the Amazon Publisher Services renderer
directly, and core's generic renderer type is defined as the APS renderer type.
The effect is that core cannot represent a bid renderer from any other vendor,
and APS cannot be moved out of core without a core change.

All references are to crates/trusted-server-js/lib/src on main at
d516a9e94.

Core imports a vendor module.

  • core/auction.ts:5: import { parseApsRendererDescriptor } from '../integrations/aps/render';, called at core/auction.ts:139 against bid.ext.trusted_server.renderer for every bid of every seat.
  • core/request.ts:2: import { dispatchApsRendering, renderApsCreative } from '../integrations/aps/render';, called at core/request.ts:56 and :59 in the render loop.

Core's generic type is the vendor's type.

  • core/types.ts:69: export type AuctionBidRenderer = ApsRendererV1;
  • core/types.ts:53, :56, :72 define ApsTagType, ApsRendererV1 and ApsPrebidRendererEntry in core.
  • core/types.ts:97: the generic renderer?: AuctionBidRenderer field on a bid therefore only ever means the APS shape.

APS is the only integration that is not a browser module. Twelve of the
thirteen integrations under lib/src/integrations/ have an index.ts and are
discovered by build-all.mjs. APS has none, so its 722-line
integrations/aps/render.ts is not built as tsjs-aps.js. It reaches the
browser only because core imports it.

It ships to every publisher. Because build-all.mjs builds core/index.ts
as a self-contained IIFE, the APS code is inlined into the shared core bundle.
On a local build of main, dist/tsjs-core.js contains
data-ts-aps-rendering-mode, integrations/aps/renderer and aaxResponse,
and there is no dist/tsjs-aps.js. A publisher who does not use Amazon still
downloads Amazon's renderer.

Why it matters

  1. A second renderer vendor cannot express itself. Any vendor whose bids
    need browser-side rendering has to be represented as ApsRendererV1, or
    core has to change. That is a core change per vendor, which is the thing the
    integration seam exists to remove.
  2. APS cannot move out whole. Generalizing the Rust BidRenderer is not
    sufficient, because the browser side would still import APS from core.
  3. Every publisher carries it. The bundle is content-hashed and shared, so
    the cost is paid by publishers who never use APS.

Suggested direction, not prescriptive

The Rust side already has the shape to copy, being an open type tag plus a
payload read back by type. The browser equivalent would be a renderer registry
keyed on the descriptor type, where an integration module registers its parser
and its dispatcher, core rejects an unknown type safely rather than failing the
slot, and AuctionBidRenderer becomes an open type. APS would then become a
discovered browser module with its own index.ts that registers itself, which
is how the other twelve already work.

A cross-language test proving APS can be removed without changing or breaking
the core bundle would be the honest acceptance criterion.

Why we are raising it and not fixing it

It does not affect us. A 51Degrees provider is an identity provider and follows
the client-cycle pattern in #1046, whose ec_client_fixed page script is a
discovered browser module that imports from core and never into it, so it needs
no core change. Every existing
integration except APS is in the same position. What is blocked is a future
vendor needing its own browser bid renderer, and no such vendor exists in the
repository today.

We also did not want to widen the scope of the open provider-seam pull requests
to cover work they do not deliver. The seam design spec has been corrected so it
claims only the Rust side, and records this browser-side gap rather than
implying it is solved.

Reproduce

git show upstream/main:crates/trusted-server-js/lib/src/core/auction.ts | grep -n Aps
git show upstream/main:crates/trusted-server-js/lib/src/core/request.ts | grep -n Aps
git show upstream/main:crates/trusted-server-js/lib/src/core/types.ts | grep -n "AuctionBidRenderer\|ApsRendererV1"
ls crates/trusted-server-js/lib/src/integrations/aps/          # no index.ts
cd crates/trusted-server-js/lib && node build-all.mjs
grep -c "data-ts-aps-rendering-mode" ../dist/tsjs-core.js      # 1
ls ../dist/ | grep -i aps                                      # no tsjs-aps.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions