Skip to content

Commit 7d28b6f

Browse files
authored
ENG-2908: Serve IAB TCF CMP stub as fides-stub.js from Privacy Center (#7642)
1 parent f08b613 commit 7d28b6f

6 files changed

Lines changed: 138 additions & 34 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
type: Added
2+
description: Added IAB TCF CMP stub served as /fides-stub.js from Privacy Center
3+
pr: 7642
4+
labels: []

clients/fides-js/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"uuid": "^9.0.0"
6464
},
6565
"devDependencies": {
66+
"@iabtechlabtcf/stub": "1.5.21",
6667
"@rollup/plugin-alias": "^5.0.0",
6768
"@rollup/plugin-commonjs": "^25.0.7",
6869
"@rollup/plugin-json": "^6.0.0",

clients/fides-js/rollup.config.mjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,48 @@ const previewScript = {
256256
// Add preview script to build after the main scripts
257257
rollupOptions.push(previewScript);
258258

259+
/**
260+
* Copy the official IAB TCF CMP stub to privacy-center as a static file.
261+
* Publishers load this before fides.js so that window.__tcfapi is available
262+
* immediately for downstream ad scripts.
263+
*
264+
* Uses a virtual module as input since there is no source to compile — we
265+
* only need rollup to run the copy plugin.
266+
*/
267+
const copyStub = {
268+
input: "\0virtual-stub",
269+
plugins: [
270+
{
271+
name: "virtual-stub",
272+
resolveId(id) {
273+
if (id === "\0virtual-stub") return id;
274+
},
275+
load(id) {
276+
if (id === "\0virtual-stub") return "// IAB TCF stub copy-only entry";
277+
},
278+
},
279+
copy({
280+
targets: [
281+
{
282+
src: "../node_modules/@iabtechlabtcf/stub/lib/stub.js",
283+
dest: "../privacy-center/public/lib/",
284+
rename: "fides-stub.js",
285+
},
286+
],
287+
verbose: true,
288+
hook: "buildStart",
289+
}),
290+
],
291+
output: [
292+
{
293+
file: "dist/fides-stub.js",
294+
format: "es",
295+
},
296+
],
297+
};
298+
299+
rollupOptions.push(copyStub);
300+
259301
/**
260302
* In addition to our regular built outputs (like fides.js!) also generate a
261303
* fides-types.d.ts file from our documented types for external use.

0 commit comments

Comments
 (0)