Skip to content

Commit 881c7db

Browse files
Merge pull request prebid#4 from prebid/master
merge from prebid master to fork
2 parents 6e856c0 + 42cd7ae commit 881c7db

File tree

274 files changed

+7207
-3591
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+7207
-3591
lines changed

.babelrc

-19
This file was deleted.

.babelrc.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
let path = require('path');
3+
4+
function useLocal(module) {
5+
return require.resolve(module, {
6+
paths: [
7+
__dirname
8+
]
9+
})
10+
}
11+
12+
module.exports = {
13+
"presets": [
14+
[
15+
useLocal('@babel/preset-env'),
16+
{
17+
"targets": {
18+
"browsers": [
19+
"chrome >= 61",
20+
"safari >=8",
21+
"edge >= 14",
22+
"ff >= 57",
23+
"ie >= 10",
24+
"ios >= 8"
25+
]
26+
}
27+
}
28+
]
29+
],
30+
"plugins": [
31+
path.resolve(__dirname, './plugins/pbjsGlobals.js'),
32+
useLocal('babel-plugin-transform-object-assign')
33+
]
34+
};

README.md

+83
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,94 @@ Working examples can be found in [the developer docs](http://prebid.org/dev-docs
1616

1717
**Table of Contents**
1818

19+
- [Usage](#Usage)
1920
- [Install](#Install)
2021
- [Build](#Build)
2122
- [Run](#Run)
2223
- [Contribute](#Contribute)
2324

25+
<a name="Usage"></a>
26+
27+
## Usage (as a npm dependency)
28+
29+
*Note:* Requires Prebid.js v1.38.0+
30+
31+
Prebid.js depends on Babel and some Babel Plugins in order to run correctly in the browser. Here are some examples for
32+
configuring webpack to work with Prebid.js.
33+
34+
With Babel 7:
35+
```javascript
36+
// webpack.conf.js
37+
let path = require('path');
38+
module.exports = {
39+
mode: 'production',
40+
module: {
41+
rules: [
42+
43+
// this rule can be excluded if you don't require babel-loader for your other application files
44+
{
45+
test: /\.m?js$/,
46+
exclude: /node_modules/,
47+
use: {
48+
loader: 'babel-loader',
49+
}
50+
},
51+
52+
// this separate rule is required to make sure that the Prebid.js files are babel-ified. this rule will
53+
// override the regular exclusion from above (for being inside node_modules).
54+
{
55+
test: /.js$/,
56+
include: new RegExp(`\\${path.sep}prebid\.js`),
57+
use: {
58+
loader: 'babel-loader',
59+
// presets and plugins for Prebid.js must be manually specified separate from your other babel rule.
60+
// this can be accomplished by requiring prebid's .babelrc.js file (requires Babel 7 and Node v8.9.0+)
61+
options: require('prebid.js/.babelrc.js')
62+
}
63+
}
64+
]
65+
}
66+
}
67+
```
68+
69+
Or for Babel 6 and/or Node v8.6.0 and less:
70+
```javascript
71+
// you must manually install and specify the presets and plugins yourself
72+
options: {
73+
plugins: [
74+
"transform-object-assign", // required (for IE support) and "babel-plugin-transform-object-assign"
75+
// must be installed as part of your package.
76+
require('prebid.js/plugins/pbjsGlobals.js') // required!
77+
],
78+
presets: [
79+
["env", { // you can use other presets if you wish.
80+
"targets": { // this example is using "babel-presets-env", which must be installed if you
81+
"browsers": [ // follow this example.
82+
... // your browser targets. they should probably match the targets you're using for the rest
83+
// of your application
84+
]
85+
}
86+
}]
87+
]
88+
}
89+
```
90+
91+
Then you can use Prebid.js as any other npm depedendency
92+
93+
```javascript
94+
import prebid from 'prebid.js';
95+
import 'prebid.js/modules/rubiconBidAdapter'; // imported modules will register themselves automatically with prebid
96+
import 'prebid.js/modules/appnexusBidAdapter';
97+
prebid.processQueue(); // required to process existing pbjs.queue blocks and setup any further pbjs.queue execution
98+
99+
prebid.requestBids({
100+
...
101+
})
102+
103+
```
104+
105+
106+
24107
<a name="Install"></a>
25108

26109
## Install

gulpHelpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module.exports = {
6666
try {
6767
var absoluteModulePath = path.join(__dirname, MODULE_PATH);
6868
internalModules = fs.readdirSync(absoluteModulePath)
69-
.filter(file => !(/(^|\/)\.[^\/\.]/g).test(file))
69+
.filter(file => (/^[^\.]+(\.js)?$/).test(file))
7070
.reduce((memo, file) => {
7171
var moduleName = file.split(new RegExp('[.\\' + path.sep + ']'))[0];
7272
var modulePath = path.join(absoluteModulePath, file);

gulpfile.js

-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ function makeDevpackPkg() {
141141
return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
142142
.pipe(helpers.nameModules(externalModules))
143143
.pipe(webpackStream(cloned, webpack))
144-
.pipe(replace('$prebid.version$', prebid.version))
145144
.pipe(gulp.dest('build/dev'))
146145
.pipe(connect.reload());
147146
}
@@ -159,7 +158,6 @@ function makeWebpackPkg() {
159158
return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
160159
.pipe(helpers.nameModules(externalModules))
161160
.pipe(webpackStream(cloned, webpack))
162-
.pipe(replace('$prebid.version$', prebid.version))
163161
.pipe(uglify())
164162
.pipe(gulpif(file => file.basename === 'prebid-core.js', header(banner, { prebid: prebid })))
165163
.pipe(optimizejs())

modules/33acrossBidAdapter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as utils from 'src/utils';
1+
import * as utils from '../src/utils';
22

33
const { registerBidder } = require('../src/adapters/bidderFactory');
44
const { config } = require('../src/config');

modules/a4gBidAdapter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {registerBidder} from 'src/adapters/bidderFactory';
2-
import * as utils from 'src/utils';
1+
import {registerBidder} from '../src/adapters/bidderFactory';
2+
import * as utils from '../src/utils';
33

44
const A4G_BIDDER_CODE = 'a4g';
55
const A4G_CURRENCY = 'USD';

modules/aardvarkBidAdapter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as utils from 'src/utils';
2-
import {registerBidder} from 'src/adapters/bidderFactory';
1+
import * as utils from '../src/utils';
2+
import {registerBidder} from '../src/adapters/bidderFactory';
33

44
const BIDDER_CODE = 'aardvark';
55
const DEFAULT_ENDPOINT = 'bidder.rtk.io';

modules/adagioAnalyticsAdapter.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Analytics Adapter for Adagio
33
*/
44

5-
import adapter from 'src/AnalyticsAdapter';
6-
import adaptermanager from 'src/adaptermanager';
5+
import adapter from '../src/AnalyticsAdapter';
6+
import adapterManager from '../src/adapterManager';
77

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

18-
adaptermanager.registerAnalyticsAdapter({
18+
adapterManager.registerAnalyticsAdapter({
1919
adapter: adagioAdapter,
2020
code: 'adagio'
2121
});

modules/adagioBidAdapter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import find from 'core-js/library/fn/array/find';
2-
import * as utils from 'src/utils';
3-
import { registerBidder } from 'src/adapters/bidderFactory';
2+
import * as utils from '../src/utils';
3+
import { registerBidder } from '../src/adapters/bidderFactory';
44

55
const BIDDER_CODE = 'adagio';
66
const VERSION = '1.0.0';

modules/adbutlerBidAdapter.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

3-
import * as utils from 'src/utils';
4-
import {config} from 'src/config';
5-
import {registerBidder} from 'src/adapters/bidderFactory';
3+
import * as utils from '../src/utils';
4+
import {config} from '../src/config';
5+
import {registerBidder} from '../src/adapters/bidderFactory';
66

77
const BIDDER_CODE = 'adbutler';
88

modules/adformBidAdapter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
import {registerBidder} from 'src/adapters/bidderFactory';
4-
import { BANNER, VIDEO } from 'src/mediaTypes';
3+
import {registerBidder} from '../src/adapters/bidderFactory';
4+
import { BANNER, VIDEO } from '../src/mediaTypes';
55

66
const BIDDER_CODE = 'adform';
77
export const spec = {

modules/adformOpenRTBBidAdapter.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
import {
55
registerBidder
6-
} from 'src/adapters/bidderFactory';
6+
} from '../src/adapters/bidderFactory';
77
import {
88
NATIVE
9-
} from 'src/mediaTypes';
10-
import * as utils from 'src/utils';
9+
} from '../src/mediaTypes';
10+
import * as utils from '../src/utils';
1111

1212
const BIDDER_CODE = 'adformOpenRTB';
1313
const NATIVE_ASSET_IDS = { 0: 'title', 2: 'icon', 3: 'image', 5: 'sponsoredBy', 4: 'body', 1: 'cta' };

modules/adgenerationBidAdapter.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as utils from 'src/utils';
2-
import {registerBidder} from 'src/adapters/bidderFactory';
3-
import {BANNER, NATIVE} from 'src/mediaTypes';
4-
import { config } from 'src/config';
1+
import * as utils from '../src/utils';
2+
import {registerBidder} from '../src/adapters/bidderFactory';
3+
import {BANNER, NATIVE} from '../src/mediaTypes';
4+
import { config } from '../src/config';
55
const ADG_BIDDER_CODE = 'adgeneration';
66

77
export const spec = {

0 commit comments

Comments
 (0)