Skip to content

Commit

Permalink
Debugging module: multiple bugfixes (prebid#8582)
Browse files Browse the repository at this point in the history
* Debugging module: fix bug with configuration not being loaded from session if module is included in the prebid bundle

* Translate '<version>-pre' to 'latest', not '<version>'

* Add CLI option to set url base for debugging-standalone.js

* Allow arrays in 'then' specification
  • Loading branch information
dgirardi authored and RomainLofaso committed Aug 8, 2022
1 parent a91260c commit 2fd4bfb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function makeDevpackPkg() {
mode: 'development'
})

const babelConfig = require('./babelConfig.js')({prebidDistUrlBase: '/build/dev/'});
const babelConfig = require('./babelConfig.js')({disableFeatures: helpers.getDisabledFeatures(), prebidDistUrlBase: argv.distUrlBase || '/build/dev/'});

// update babel config to set local dist url
cloned.module.rules
Expand Down
2 changes: 1 addition & 1 deletion modules/debugging/bidInterceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Object.assign(BidInterceptor.prototype, {
replFn = () => ({});
} else {
replFn = ({args, ref = replDef}) => {
const result = {};
const result = Array.isArray(ref) ? [] : {};
Object.entries(ref).forEach(([key, val]) => {
if (typeof val === 'function') {
result[key] = val(...args);
Expand Down
3 changes: 2 additions & 1 deletion modules/debugging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import {hook} from '../../src/hook.js';
import {install} from './debugging.js';
import {prefixLog} from '../../src/utils.js';
import {createBid} from '../../src/bidfactory.js';
import {DEBUG_KEY} from '../../src/debugging.js';

install({config, hook, createBid, logger: prefixLog('DEBUG:')});
install({DEBUG_KEY, config, hook, createBid, logger: prefixLog('DEBUG:')});
3 changes: 2 additions & 1 deletion plugins/pbjsGlobals.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function featureMap(disable = []) {

function getNpmVersion(version) {
try {
return /^(.*?)(-pre)?$/.exec(version)[1];
// only use "real" versions (that is, not the -pre ones, they won't be on jsDelivr)
return /^([\d.]+)$/.exec(version)[1];
} catch (e) {
return 'latest';
}
Expand Down
7 changes: 7 additions & 0 deletions test/spec/modules/debugging_mod_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ describe('bid interceptor', () => {
expect(result).to.include.keys(REQUIRED_KEYS);
expect(result.outer.inner).to.eql({key: 'value'});
});

it('should respect array vs object definitions', () => {
const result = matchingRule({replace: {item: [replDef]}}).replace({});
expect(result.item).to.be.an('array');
expect(result.item.length).to.equal(1);
expect(result.item[0]).to.eql({key: 'value'});
});
});
});

Expand Down
2 changes: 1 addition & 1 deletion webpack.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var webpack = require('webpack');
var helpers = require('./gulpHelpers.js');
var { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
var argv = require('yargs').argv;
const babelConfig = require('./babelConfig.js')({disableFeatures: helpers.getDisabledFeatures()});
const babelConfig = require('./babelConfig.js')({disableFeatures: helpers.getDisabledFeatures(), prebidDistUrlBase: argv.distUrlBase});

var plugins = [
new webpack.EnvironmentPlugin({'LiveConnectMode': null}),
Expand Down

0 comments on commit 2fd4bfb

Please sign in to comment.