Skip to content

Build sytem: allow customization of some build options (such as global name) to NPM consumers #13685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 28, 2025

Conversation

dgirardi
Copy link
Collaborator

@dgirardi dgirardi commented Jul 28, 2025

Type of change

  • Feature

Description of change

This reintroduces the ability for NPM consumers to customize some build options, namely globalVarName, defineGlobal, and distUrlBase.

The approach is:

  • replace all uses of the corresponding macros ($$PREBID_GLOBAL$$, etc) with normal function calls;
  • the function looks up a table that is generated during precompilation;
  • values in the table can be customized with a custom webpack loader (customize/webpackLoader.mjs).

Other information

Closes #13657

@@ -31,6 +31,8 @@ import { _ADAGIO, getBestWindowForAdagio } from '../libraries/adagioUtils/adagio
import { getGptSlotInfoForAdUnitCode } from '../libraries/gptUtils/gptUtils.js';
import { getBoundingClientRect } from '../libraries/boundingClientRect/boundingClientRect.js';

import {getGlobalVarName} from '../src/buildOptions.js';
Copy link
Collaborator

Choose a reason for hiding this comment

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

how is this different than

import {getGlobal} from '../src/prebidGlobal.js';

Copy link
Collaborator Author

@dgirardi dgirardi Jul 28, 2025

Choose a reason for hiding this comment

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

getGlobal returns the global object (the one that has .requestBids() etc); getGlobalVarName returns the global name (e.g. 'pbjs').

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 16577532621

Details

  • 392 of 395 (99.24%) changed or added relevant lines in 60 files are covered.
  • 10 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+0.001%) to 96.258%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/prebid.ts 3 4 75.0%
test/spec/modules/twistDigitalBidAdapter_spec.js 6 8 75.0%
Files with Coverage Reduction New Missed Lines %
libraries/smartyadsUtils/getAdUrlByRegion.js 1 64.29%
libraries/timeToFirstBytesUtils/timeToFirstBytesUtils.js 1 83.33%
modules/beachfrontBidAdapter.js 1 95.57%
modules/bliinkBidAdapter.js 1 96.49%
modules/eskimiBidAdapter.js 1 75.86%
src/utils.js 1 88.84%
test/spec/modules/teadsBidAdapter_spec.js 1 98.21%
modules/axonixBidAdapter.js 3 81.03%
Totals Coverage Status
Change from base Build 16571826174: 0.001%
Covered Lines: 194883
Relevant Lines: 202459

💛 - Coveralls

@patmmccann patmmccann merged commit af15395 into master Jul 28, 2025
20 checks passed
@patmmccann patmmccann deleted the allow-global-def branch July 28, 2025 20:11
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.

Importing prebid.js as a module broken in v10
3 participants