Skip to content

Commit

Permalink
Merge pull request #79 from guardian/kc-upstream
Browse files Browse the repository at this point in the history
Merge release 1.39.0 from upstream
  • Loading branch information
kelvin-chappell authored Jan 29, 2019
2 parents 4e6ba26 + 94b5762 commit d67625d
Show file tree
Hide file tree
Showing 299 changed files with 10,074 additions and 6,502 deletions.
19 changes: 0 additions & 19 deletions .babelrc

This file was deleted.

34 changes: 34 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

let path = require('path');

function useLocal(module) {
return require.resolve(module, {
paths: [
__dirname
]
})
}

module.exports = {
"presets": [
[
useLocal('@babel/preset-env'),
{
"targets": {
"browsers": [
"chrome >= 61",
"safari >=8",
"edge >= 14",
"ff >= 57",
"ie >= 10",
"ios >= 8"
]
}
}
]
],
"plugins": [
path.resolve(__dirname, './plugins/pbjsGlobals.js'),
useLocal('babel-plugin-transform-object-assign')
]
};
87 changes: 85 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,95 @@ Working examples can be found in [the developer docs](http://prebid.org/dev-docs

**Table of Contents**

- [Usage](#Usage)
- [Install](#Install)
- [Build](#Build)
- [Run](#Run)
- [Contribute](#Contribute)
- [Guardian optimised build](#guardian-optimised-build)

<a name="Usage"></a>

## Usage (as a npm dependency)

*Note:* Requires Prebid.js v1.38.0+

Prebid.js depends on Babel and some Babel Plugins in order to run correctly in the browser. Here are some examples for
configuring webpack to work with Prebid.js.

With Babel 7:
```javascript
// webpack.conf.js
let path = require('path');
module.exports = {
mode: 'production',
module: {
rules: [

// this rule can be excluded if you don't require babel-loader for your other application files
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
}
},

// this separate rule is required to make sure that the Prebid.js files are babel-ified. this rule will
// override the regular exclusion from above (for being inside node_modules).
{
test: /.js$/,
include: new RegExp(`\\${path.sep}prebid\.js`),
use: {
loader: 'babel-loader',
// presets and plugins for Prebid.js must be manually specified separate from your other babel rule.
// this can be accomplished by requiring prebid's .babelrc.js file (requires Babel 7 and Node v8.9.0+)
options: require('prebid.js/.babelrc.js')
}
}
]
}
}
```

Or for Babel 6 and/or Node v8.6.0 and less:
```javascript
// you must manually install and specify the presets and plugins yourself
options: {
plugins: [
"transform-object-assign", // required (for IE support) and "babel-plugin-transform-object-assign"
// must be installed as part of your package.
require('prebid.js/plugins/pbjsGlobals.js') // required!
],
presets: [
["env", { // you can use other presets if you wish.
"targets": { // this example is using "babel-presets-env", which must be installed if you
"browsers": [ // follow this example.
... // your browser targets. they should probably match the targets you're using for the rest
// of your application
]
}
}]
]
}
```

Then you can use Prebid.js as any other npm depedendency

```javascript
import prebid from 'prebid.js';
import 'prebid.js/modules/rubiconBidAdapter'; // imported modules will register themselves automatically with prebid
import 'prebid.js/modules/appnexusBidAdapter';
prebid.processQueue(); // required to process existing pbjs.queue blocks and setup any further pbjs.queue execution

prebid.requestBids({
...
})

```



<a name="Install"></a>

## Install
Expand All @@ -30,7 +113,7 @@ Working examples can be found in [the developer docs](http://prebid.org/dev-docs
$ cd Prebid.js
$ npm install

*Note:* You need to have `NodeJS` 4.x or greater installed.
*Note:* You need to have `NodeJS` 6.x or greater installed.

*Note:* In the 1.24.0 release of Prebid.js we have transitioned to using gulp 4.0 from using gulp 3.9.1. To compily with gulp's recommended setup for 4.0, you'll need to have `gulp-cli` installed globally prior to running the general `npm install`. This shouldn't impact any other projects you may work on that use an earlier version of gulp in it's setup.

Expand Down Expand Up @@ -218,7 +301,7 @@ For instructions on writing tests for Prebid.js, see [Testing Prebid.js](http://

### Supported Browsers

Prebid.js is supported on IE10+ and modern browsers.
Prebid.js is supported on IE11 and modern browsers.

### Governance
Review our governance model [here](https://github.com/prebid/Prebid.js/tree/master/governance.md).
Expand Down
28 changes: 14 additions & 14 deletions build/dist/prebid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gulpHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = {
try {
var absoluteModulePath = path.join(__dirname, MODULE_PATH);
internalModules = fs.readdirSync(absoluteModulePath)
.filter(file => !(/(^|\/)\.[^\/\.]/g).test(file))
.filter(file => (/^[^\.]+(\.js)?$/).test(file))
.reduce((memo, file) => {
var moduleName = file.split(new RegExp('[.\\' + path.sep + ']'))[0];
var modulePath = path.join(absoluteModulePath, file);
Expand Down
61 changes: 31 additions & 30 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ var _ = require('lodash');
var argv = require('yargs').argv;
var gulp = require('gulp');
var gutil = require('gulp-util');
var webserver = require('gulp-webserver');
var connect = require('gulp-connect');
var webpack = require('webpack');
var webpackStream = require('webpack-stream');
var uglify = require('gulp-uglify');
var gulpClean = require('gulp-clean');
var KarmaServer = require('karma').Server;
var karmaConfMaker = require('./karma.conf.maker');
var opens = require('open');
var opens = require('opn');
var webpackConfig = require('./webpack.conf');
var helpers = require('./gulpHelpers');
var concat = require('gulp-concat');
Expand Down Expand Up @@ -56,12 +56,11 @@ function e2etestReport() {
var reportPort = 9010;
var targetDestinationDir = './e2etest-report';
helpers.createEnd2EndTestReport(targetDestinationDir);
gulp.src('./')
.pipe(webserver({
port: reportPort,
directoryListing: true,
livereload: true
}));
connect.server({
port: reportPort,
root: './',
livereload: true
});

setTimeout(function() {
opens('http://localhost:' + reportPort + '/' + targetDestinationDir.slice(2) + '/results.html');
Expand All @@ -81,25 +80,29 @@ function lint(done) {
if (argv.nolint) {
return done();
}
return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'])
.pipe(eslint())
const isFixed = function(file) {
return file.eslint != null && file.eslint.fixed;
}
return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'], {base: './'})
.pipe(eslint({fix: true}))
.pipe(eslint.format('stylish'))
.pipe(eslint.failAfterError());
.pipe(eslint.failAfterError())
.pipe(gulpif(isFixed, gulp.dest('./')));
};

// View the code coverage report in the browser.
function viewCoverage(done) {
var coveragePort = 1999;

var stream = gulp.src('./')
.pipe(webserver({
port: coveragePort,
directoryListing: true,
livereload: false,
open: 'build/coverage/karma_html/index.html'
}));
stream.on('finish', done);
connect.server({
port: coveragePort,
root: 'build/coverage/karma_html',
livereload: false
});
opens('http://localhost:' + coveragePort);
done();
};

viewCoverage.displayName = 'view-coverage';

// Watch Task with Live Reload
Expand All @@ -115,17 +118,16 @@ function watch(done) {
'test/spec/loaders/**/*.js'
]);

var stream = gulp.src('./')
.pipe(webserver({
https: argv.https,
port: port,
directoryListing: true,
livereload: true
}));
connect.server({
https: argv.https,
port: port,
root: './',
livereload: true
});

mainWatcher.on('all', gulp.series(clean, gulp.parallel(lint, 'build-bundle-dev', test)));
loaderWatcher.on('all', gulp.series(lint));
stream.on('finish', done);
done();
};

function makeDevpackPkg() {
Expand All @@ -139,8 +141,8 @@ function makeDevpackPkg() {
return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
.pipe(helpers.nameModules(externalModules))
.pipe(webpackStream(cloned, webpack))
.pipe(replace('$prebid.version$', prebid.version))
.pipe(gulp.dest('build/dev'));
.pipe(gulp.dest('build/dev'))
.pipe(connect.reload());
}

function makeWebpackPkg() {
Expand All @@ -156,7 +158,6 @@ function makeWebpackPkg() {
return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
.pipe(helpers.nameModules(externalModules))
.pipe(webpackStream(cloned, webpack))
.pipe(replace('$prebid.version$', prebid.version))
.pipe(uglify())
.pipe(gulpif(file => file.basename === 'prebid-core.js', header(banner, { prebid: prebid })))
.pipe(optimizejs())
Expand Down
7 changes: 5 additions & 2 deletions karma.conf.maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ function newWebpackConfig(codeCoverage) {
webpackConfig.module.rules.push({
enforce: 'post',
exclude: /(node_modules)|(test)|(integrationExamples)|(build)|polyfill.js|(src\/adapters\/analytics\/ga.js)/,
loader: 'istanbul-instrumenter-loader',
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
},
test: /\.js$/
})
}
Expand All @@ -34,7 +37,6 @@ function newPluginsArray(browserstack) {
'karma-es5-shim',
'karma-mocha',
'karma-chai',
'karma-requirejs',
'karma-sinon',
'karma-sourcemap-loader',
'karma-spec-reporter',
Expand Down Expand Up @@ -125,6 +127,7 @@ module.exports = function(codeCoverage, browserstack, watchMode, file) {

webpack: webpackConfig,
webpackMiddleware: {
stats: 'errors-only',
noInfo: true
},
// frameworks to use
Expand Down
2 changes: 1 addition & 1 deletion modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from 'src/utils';
import * as utils from '../src/utils';

const { registerBidder } = require('../src/adapters/bidderFactory');
const { config } = require('../src/config');
Expand Down
4 changes: 2 additions & 2 deletions modules/a4gBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {registerBidder} from 'src/adapters/bidderFactory';
import * as utils from 'src/utils';
import {registerBidder} from '../src/adapters/bidderFactory';
import * as utils from '../src/utils';

const A4G_BIDDER_CODE = 'a4g';
const A4G_CURRENCY = 'USD';
Expand Down
4 changes: 2 additions & 2 deletions modules/aardvarkBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as utils from 'src/utils';
import {registerBidder} from 'src/adapters/bidderFactory';
import * as utils from '../src/utils';
import {registerBidder} from '../src/adapters/bidderFactory';

const BIDDER_CODE = 'aardvark';
const DEFAULT_ENDPOINT = 'bidder.rtk.io';
Expand Down
6 changes: 3 additions & 3 deletions modules/adagioAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Analytics Adapter for Adagio
*/

import adapter from 'src/AnalyticsAdapter';
import adaptermanager from 'src/adaptermanager';
import adapter from '../src/AnalyticsAdapter';
import adapterManager from '../src/adapterManager';

// This config makes Prebid.js call this function on each event:
// `window['AdagioPrebidAnalytics']('on', eventType, args)`
Expand All @@ -15,7 +15,7 @@ var adagioAdapter = adapter({
analyticsType: 'bundle'
});

adaptermanager.registerAnalyticsAdapter({
adapterManager.registerAnalyticsAdapter({
adapter: adagioAdapter,
code: 'adagio'
});
Expand Down
4 changes: 2 additions & 2 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import find from 'core-js/library/fn/array/find';
import * as utils from 'src/utils';
import { registerBidder } from 'src/adapters/bidderFactory';
import * as utils from '../src/utils';
import { registerBidder } from '../src/adapters/bidderFactory';

const BIDDER_CODE = 'adagio';
const VERSION = '1.0.0';
Expand Down
Loading

0 comments on commit d67625d

Please sign in to comment.